Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. date format (UK)

date format (UK)

Scheduled Pinned Locked Moved C#
debuggingworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pedros73 0
    wrote on last edited by
    #1

    I'm using the following so I can format all my dates relvant to the current culture of the OS. The app is for global use private DateTimeFormatInfo dtFormatInfo; this.dtFormatInfo = Thread.CurrentThread.CurrentUICulture.DateTimeFormat; I have then created a property to format any dates in ShortDatePattern public string ShortDateFmt { get { return this.dtFormatInfo.ShortDatePattern; } } Every time I run my application and process a date it returns in the format mm\dd\yyyy when running on an OS with United Kingdom setup (en-GB). en-GB date format should be dd/mm/yyyy I have even created the follwing property so as to debug and check the CurrentUICulture public string CurrentUICultureName { get { return Thread.CurrentThread.CurrentUICulture.Name; } } and this is returning en-GB. Any suggestions as to why the date is not formatting for en-GB

    G 1 Reply Last reply
    0
    • P pedros73 0

      I'm using the following so I can format all my dates relvant to the current culture of the OS. The app is for global use private DateTimeFormatInfo dtFormatInfo; this.dtFormatInfo = Thread.CurrentThread.CurrentUICulture.DateTimeFormat; I have then created a property to format any dates in ShortDatePattern public string ShortDateFmt { get { return this.dtFormatInfo.ShortDatePattern; } } Every time I run my application and process a date it returns in the format mm\dd\yyyy when running on an OS with United Kingdom setup (en-GB). en-GB date format should be dd/mm/yyyy I have even created the follwing property so as to debug and check the CurrentUICulture public string CurrentUICultureName { get { return Thread.CurrentThread.CurrentUICulture.Name; } } and this is returning en-GB. Any suggestions as to why the date is not formatting for en-GB

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The ShortDatePattern does not specify the date separator, so when you use a pattern from a culture other than the current culture, the separator will still be taken from the current culture. Use the CultureInfo object or DateTimeFormat object to format the date instead. They also contain information about the date separator. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups