locked
get current date format RRS feed

  • Question

  • Hi,


    How can i get current date format of the system.
    I need only format not the date.


    Thanks..in advance

    • Moved by Amanda Zhu Tuesday, December 10, 2013 8:34 AM not VS general issue and not sure where it can be moved to
    Thursday, December 5, 2013 6:06 AM

Answers

  • try this:

    string localDateFormat = CultureInfo.CurrentCulture.DateTimeFormat;

    You should get the date format in localDateFormat variable.


    Kunal G

    • Proposed as answer by Just Karl Tuesday, December 10, 2013 9:09 PM
    • Marked as answer by Just Karl Thursday, December 19, 2013 10:23 PM
    Thursday, December 5, 2013 6:31 AM
  • use System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.FullDateTimePattern;

    This will return the format as String , eg - "dddd, MMMM dd, yyyy h:mm:ss tt"


    ----------------------------------------------------------------------------------

    Regards
    alwayzLearning

    The belief in a thing makes it happen!!!

    • Edited by alwayzLearning Thursday, December 5, 2013 7:03 AM
    • Proposed as answer by Just Karl Tuesday, December 10, 2013 9:09 PM
    • Marked as answer by Just Karl Thursday, December 19, 2013 10:23 PM
    Thursday, December 5, 2013 7:02 AM

All replies

  • try this:

    string localDateFormat = CultureInfo.CurrentCulture.DateTimeFormat;

    You should get the date format in localDateFormat variable.


    Kunal G

    • Proposed as answer by Just Karl Tuesday, December 10, 2013 9:09 PM
    • Marked as answer by Just Karl Thursday, December 19, 2013 10:23 PM
    Thursday, December 5, 2013 6:31 AM
  • use System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.FullDateTimePattern;

    This will return the format as String , eg - "dddd, MMMM dd, yyyy h:mm:ss tt"


    ----------------------------------------------------------------------------------

    Regards
    alwayzLearning

    The belief in a thing makes it happen!!!

    • Edited by alwayzLearning Thursday, December 5, 2013 7:03 AM
    • Proposed as answer by Just Karl Tuesday, December 10, 2013 9:09 PM
    • Marked as answer by Just Karl Thursday, December 19, 2013 10:23 PM
    Thursday, December 5, 2013 7:02 AM
  • Hello,

    Please ask in the Visual C# Language forum on MSDN.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog:http://unlockpowershell.wordpress.com
    My Book:Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})


    • Edited by Just Karl Tuesday, December 10, 2013 9:20 PM
    Tuesday, December 10, 2013 9:17 PM