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. Format DateTime to string with no seconds

Format DateTime to string with no seconds

Scheduled Pinned Locked Moved C#
tutorial
6 Posts 5 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.
  • A Offline
    A Offline
    anderslundsgard
    wrote on last edited by
    #1

    I want to format a DateTime value into a string. The thing is that I’m developing a Multilanguage application and I want to format the string according to the users culture. For example: Swedish: YYYY:MM:DD HH:mm English: DD/MM/YYYY HH:mm

    _____________________________ ...and justice for all

    C E R P 4 Replies Last reply
    0
    • A anderslundsgard

      I want to format a DateTime value into a string. The thing is that I’m developing a Multilanguage application and I want to format the string according to the users culture. For example: Swedish: YYYY:MM:DD HH:mm English: DD/MM/YYYY HH:mm

      _____________________________ ...and justice for all

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I believe there's a ToString method that uses the local culture, or that takes the culture at least, so you can ask the system for it ).

      Christian Graus Driven to the arms of OSX by Vista.

      A 1 Reply Last reply
      0
      • A anderslundsgard

        I want to format a DateTime value into a string. The thing is that I’m developing a Multilanguage application and I want to format the string according to the users culture. For example: Swedish: YYYY:MM:DD HH:mm English: DD/MM/YYYY HH:mm

        _____________________________ ...and justice for all

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        If you are creating a multi-language application you should use the ToShortDateString, etc methods which are based on the current culture settings of the application. http://msdn.microsoft.com/en-us/library/system.datetime.toshortdatestring.aspx[^]

        Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
        If you don't ask questions the answers won't stand in your way.
        Most of this sig is for Google, not ego.

        1 Reply Last reply
        0
        • A anderslundsgard

          I want to format a DateTime value into a string. The thing is that I’m developing a Multilanguage application and I want to format the string according to the users culture. For example: Swedish: YYYY:MM:DD HH:mm English: DD/MM/YYYY HH:mm

          _____________________________ ...and justice for all

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #4

          string myDate = DateTime.Now.ToString("dd/MM/YYYY HH:mm");

          Why was this post voted a 1?

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          modified on Wednesday, January 21, 2009 1:35 PM

          1 Reply Last reply
          0
          • A anderslundsgard

            I want to format a DateTime value into a string. The thing is that I’m developing a Multilanguage application and I want to format the string according to the users culture. For example: Swedish: YYYY:MM:DD HH:mm English: DD/MM/YYYY HH:mm

            _____________________________ ...and justice for all

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Yeah, what they said, but you should only use ISO 8601-compliant date formats: yyyy-MM-dd HH:mm

            1 Reply Last reply
            0
            • C Christian Graus

              I believe there's a ToString method that uses the local culture, or that takes the culture at least, so you can ask the system for it ).

              Christian Graus Driven to the arms of OSX by Vista.

              A Offline
              A Offline
              anderslundsgard
              wrote on last edited by
              #6

              DateTime.ToString("g") made it for me.

              _____________________________ ...and justice for all

              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