Click here to Skip to main content
12,634,101 members (26,815 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi ,,
i want to get Date from DateTime class Properties ,, but its give me a wrong answer


  DateTime d=new DateTime();
  Response.Write(d.Date);


the answer is : 1/1/0001 12:00:00 AM !!!!

i need a little help ... tanQ's
Posted 18-Nov-12 19:42pm
mahmii273
Comments
   
What happened? MSDN broken?!
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Of course: this is exactly what you should have obtained. And what did you expect? Current time? This is DateTime.Now? Something else? Read http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

—SA
  Permalink  
Comments
mahmii 19-Nov-12 1:02am
   
TanQ's
Sergey Alexandrovich Kryukov 19-Nov-12 11:46am
   
Sure.
Are you going to accept the answer formally then (green button)? -- thanks.
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Yes it will return 1/1/0001 12:00:00 AM.

For current datetime use:

DateTime d=DateTime.Now;
Response.Write(d.Date);
  Permalink  
Comments
mahmii 19-Nov-12 1:02am
   
TanQ's :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Once try this.

var now = new Date().toDateString();
  Permalink  
Comments
mahmii 19-Nov-12 1:02am
   
TanQ's
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

datetime object.now will generate present date and time.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100