Click here to Skip to main content
Rate this: bad
good
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 18:42pm
mahmii273
Comments
Sergey Alexandrovich Kryukov at 19-Nov-12 0:49am
   
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 at 19-Nov-12 1:02am
   
TanQ's
Sergey Alexandrovich Kryukov at 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 at 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 at 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
0 OriginalGriff 420
1 CHill60 410
2 Sergey Alexandrovich Kryukov 384
3 PIEBALDconsult 245
4 BillWoodruff 243


Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
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