Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 17, 2008 09:47 AM by sirdneo
Contributor
6515 Points
3317 Posts
Dec 16, 2008 07:06 AM|LINK
Hi,
How about the way to convert it to a text?
All-Star
182787 Points
23484 Posts
ASPInsiders
Moderator
MVP
Dec 16, 2008 07:23 AM|LINK
you simply use the ToString() method on it. Another once could be ToShortDateString().
DateTime.Now.ToString();
In the ToString method you can also pass in arguments to mark up the output. Take a look at the documentation: http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx.
Grz, Kris.
2670 Points
512 Posts
Dec 16, 2008 07:25 AM|LINK
Star
11225 Points
1815 Posts
Dec 16, 2008 07:29 AM|LINK
string strDate = DateTime.Now.ToString();
Member
40 Points
6 Posts
Dec 16, 2008 07:37 AM|LINK
DateTime.Now.ToLocalTime().ToString()
2364 Points
590 Posts
Dec 16, 2008 07:49 AM|LINK
when you use DateTime.Now.ToString()
or DateTime.Now.ToShortDateString() and so on...
as its clear from the method itself, it gets converted to string type.
consequently parse can also be used to
dateString = "16/02/2008 12:15:12"
DateTime.Parse(datestring);
32835 Points
5563 Posts
Dec 16, 2008 08:00 AM|LINK
Hi,wmec
U can Go for
15171 Points
2509 Posts
Dec 17, 2008 09:47 AM|LINK
You can use:-
DateTime.Now.ToString("dd/MMM/YYYY"); to convert the datetime to string date.
DateTime.Now.ToString("hh:mm:ss tt"); to convert datetime to string time.
DateTime.Now.ToString("dd/MMM/YYYY hh:mm:ss tt"); to convert datetime to string Date and time.
Most of the guys have given the answer to your post so plz close this post and mark replies answer.
dateTime conversion
wmec
Contributor
6515 Points
3317 Posts
DateTime.Now
Dec 16, 2008 07:06 AM|LINK
Hi,
How about the way to convert it to a text?
HuaMin Chen
XIII
All-Star
182787 Points
23484 Posts
ASPInsiders
Moderator
MVP
Re: DateTime.Now
Dec 16, 2008 07:23 AM|LINK
Hi,
you simply use the ToString() method on it. Another once could be ToShortDateString().
DateTime.Now.ToString();
In the ToString method you can also pass in arguments to mark up the output. Take a look at the documentation: http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
skvignesh
Contributor
2670 Points
512 Posts
Re: DateTime.Now
Dec 16, 2008 07:25 AM|LINK
S.K.Vignesh
amit.jain
Star
11225 Points
1815 Posts
Re: DateTime.Now
Dec 16, 2008 07:29 AM|LINK
string strDate = DateTime.Now.ToString();
amiT jaiN
ASP.NET C# VB Articles And Code Examples
venkataramuc
Member
40 Points
6 Posts
Re: DateTime.Now
Dec 16, 2008 07:37 AM|LINK
DateTime.Now.ToLocalTime().ToString()
hs_jha
Contributor
2364 Points
590 Posts
Re: DateTime.Now
Dec 16, 2008 07:49 AM|LINK
when you use DateTime.Now.ToString()
or DateTime.Now.ToShortDateString() and so on...
as its clear from the method itself, it gets converted to string type.
consequently parse can also be used to
dateString = "16/02/2008 12:15:12"asp.net consultant
raghav_khung...
All-Star
32835 Points
5563 Posts
MVP
Re: DateTime.Now
Dec 16, 2008 08:00 AM|LINK
Hi,wmec
U can Go for
DateTime.Now.ToString(); DateTime.Now.ToShortDateString(); DateTime.Now.ToShortTimeString() ; DateTime.Now.ToLongDateString() ; DateTime.Now.ToLongTimeString() ;sirdneo
All-Star
15171 Points
2509 Posts
Re: DateTime.Now
Dec 17, 2008 09:47 AM|LINK
You can use:-
DateTime.Now.ToString("dd/MMM/YYYY"); to convert the datetime to string date.
DateTime.Now.ToString("hh:mm:ss tt"); to convert datetime to string time.
DateTime.Now.ToString("dd/MMM/YYYY hh:mm:ss tt"); to convert datetime to string Date and time.
Most of the guys have given the answer to your post so plz close this post and mark replies answer.
dateTime conversion
Zeeshan Umar
~Please Mark As Answer, one or multiple posts, which helped you. So that it might be useful for others~