Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I get the date formate like MM-DD-YYYY from DB.
Now this date displays in front end based on Keyboard settings.
Please guide me ...

Thanks & Regards,
Anilkumar.M
Posted
Updated 14-Oct-12 21:17pm
v2

1 solution

The System.DateTime.Now property returns a System.DateTime. This is stored in memory in a binary format that most programmers in most circumstances have no need to think about. When you display a DateTime value, or convert it to a string for any other reason, it is converted according to a format string, which can specify any format you like.

In this last sense, the answer to your question "if I get DateTime.Now, which Date Time Format is this using?" is "it is not using any DateTime format at all, because you haven't formatted it yet".

You specify the format by calling an overload of ToString, or (optionally) if you use System.String.Format. There is a default format, as well, so you don't always have to specify the format.

C#
string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat; 



and apply the same format on your output data time format, pleaselet me know if you want some thing specific.

Thanks,
Ambesha
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900