Click here to Skip to main content
13,046,087 members (66,723 online)
Rate this:
Please Sign up or sign in to vote.
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,
Posted 14-Oct-12 21:01pm
Updated 14-Oct-12 21:17pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

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.


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.170713.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2017
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