Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When displaying a DateTime object, there are two things to keep in mind.</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx" rel="nofollow">Culture settings</a>: when you don't specify an explicit culture, the culture that's set by the system your application is running on is used.</li> <li><a href="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx" rel="nofollow">Format strings</a>: when converting a DateTime object to a string, you can give it a format string as an argument that specifies how your DateTime object should be formatted. Something like: "d" for a short date pattern or "t" to only display the time.</li> </ul> <p>Combining these two will give you full control over how to display your <code>DateTime</code> objects. You should however be careful in forcing a certain culture setting on the user. If your application should support globalization (so multiple users from different cultures can use your app) you shouldn't depend on a specific culture. Instead, you should store all your data culture-insensitive and format it with the users culture when you display it on screen.</p> <p>Here is an example how to use both the CultureInfo object and a format string:</p> <pre><code>string myDate = "10-05-2013 08:52:30"; DateTime date = DateTime.Parse(myDate); Console.WriteLine(date.ToString("d", new CultureInfo("en-US"))); // 5/10/2013 Console.WriteLine(date.ToString("d", new CultureInfo("nl-NL"))); // 10-5-2013 Console.WriteLine(date.ToString("f", new CultureInfo("nl-NL"))); // vrijdag 10 mei 2013 08:52 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload