Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's almost the same, simply use the <code>DateTime.ToString()</code> method, e.g:</p> <pre><code>DateTime.Now.ToString("dd/MM/yy"); </code></pre> <p>Or:</p> <pre><code>DateTime dt = GetDate(); // GetDate() returns some date dt.ToString("dd/MM/yy"); </code></pre> <p>In addition, you might want to consider using one of the predefined date/time formats, e.g:</p> <pre><code>DateTime.Now.ToString("g"); // returns "02/01/2009 9:07 PM" for en-US // or "01.02.2009 21:07" for de-CH </code></pre> <p>These ensure that the format will be correct, independent of the current locale settings. </p> <p>Check the following MSDN pages for more information</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx" rel="noreferrer">DateTime.ToString() method</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/az4se3k1.aspx" rel="noreferrer">Standard Date and Time Format Strings</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx" rel="noreferrer">Custom Date and Time Format Strings</a></li> </ul> <hr> <p>Some additional, related information:</p> <p>If you want to display a date in a specific locale / culture, then there is an overload of the <code>ToString()</code> method that takes an <code>IFormatProvider</code>:</p> <pre><code>DateTime dt = GetDate(); dt.ToString("g", new CultureInfo("en-US")); // returns "5/26/2009 10:39 PM" dt.ToString("g", new CultureInfo("de-CH")); // returns "26.05.2009 22:39" </code></pre> <p>Or alternatively, you can set the <code>CultureInfo</code> of the current thread prior to formatting a date:</p> <pre><code>Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); dt.ToString("g"); // returns "5/26/2009 10:39 PM" Thread.CurrentThread.CurrentCulture = new CultureInfo("de-CH"); dt.ToString("g"); // returns "26.05.2009 22:39" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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