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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. date time format

date time format

Scheduled Pinned Locked Moved C#
regexxmlquestion
7 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.
  • J Offline
    J Offline
    justintimberlake
    wrote on last edited by
    #1

    how can i convert mm/dd/yyyy hh:mm date format to current computer date format. i have date and time as string in xml file like 7/4/2007 4:48 PM now i need to match it with cuurent time i.e System.Datetime.Now() if the current computer date time format it like mm-dd-yyy hh:mm(which i am not sure can in any format) so i want to convert my datetime to current computer date time format. How can i achieve it. i am using framework 1.1

    K M N 3 Replies Last reply
    0
    • J justintimberlake

      how can i convert mm/dd/yyyy hh:mm date format to current computer date format. i have date and time as string in xml file like 7/4/2007 4:48 PM now i need to match it with cuurent time i.e System.Datetime.Now() if the current computer date time format it like mm-dd-yyy hh:mm(which i am not sure can in any format) so i want to convert my datetime to current computer date time format. How can i achieve it. i am using framework 1.1

      K Offline
      K Offline
      ken tachyon
      wrote on last edited by
      #2

      You didn't specify the source of "your" date time format but it really shouldn't matter. If nothing else you can compare the individual fields. DateTime tmp = DateTime.Now(); if ( your.year == tmp.year && your.month == tmp.month ... You get the idea. If you use visual studio put the cursor on DataTime and press F1.:) ken.tachyon

      J 1 Reply Last reply
      0
      • K ken tachyon

        You didn't specify the source of "your" date time format but it really shouldn't matter. If nothing else you can compare the individual fields. DateTime tmp = DateTime.Now(); if ( your.year == tmp.year && your.month == tmp.month ... You get the idea. If you use visual studio put the cursor on DataTime and press F1.:) ken.tachyon

        J Offline
        J Offline
        justintimberlake
        wrote on last edited by
        #3

        if my date time format is mm/dd/yyyy i.e in xml file and current computer date time format is mm-dd-yyyy can i convert my datetime string to new date time or is it that i have to parse individually year month date hour and minute and then compare

        V K 2 Replies Last reply
        0
        • J justintimberlake

          if my date time format is mm/dd/yyyy i.e in xml file and current computer date time format is mm-dd-yyyy can i convert my datetime string to new date time or is it that i have to parse individually year month date hour and minute and then compare

          V Offline
          V Offline
          Vikram A Punathambekar
          wrote on last edited by
          #4

          If you know the input format, you can parse it manually to get the date, month and year. With this, you can construct a DateTime object and convert it to whatever format you please using the ToString() method and its overloads. Alternatively, you could just build the date string you need using the date, month and year that you've extracted. A word of advice - if you're exchanging data between different apps, the ISO format (yyyy-MM-dd) is the only sane thing to use.

          Cheers, Vıkram.


          After all is said and done, much is said and little is done.

          1 Reply Last reply
          0
          • J justintimberlake

            how can i convert mm/dd/yyyy hh:mm date format to current computer date format. i have date and time as string in xml file like 7/4/2007 4:48 PM now i need to match it with cuurent time i.e System.Datetime.Now() if the current computer date time format it like mm-dd-yyy hh:mm(which i am not sure can in any format) so i want to convert my datetime to current computer date time format. How can i achieve it. i am using framework 1.1

            M Offline
            M Offline
            Muhammad Gouda
            wrote on last edited by
            #5

            Try: DateTime.ParseExact()That takes the date/time as string and the format as string array.

            Mohamed Gouda Egypt

            1 Reply Last reply
            0
            • J justintimberlake

              how can i convert mm/dd/yyyy hh:mm date format to current computer date format. i have date and time as string in xml file like 7/4/2007 4:48 PM now i need to match it with cuurent time i.e System.Datetime.Now() if the current computer date time format it like mm-dd-yyy hh:mm(which i am not sure can in any format) so i want to convert my datetime to current computer date time format. How can i achieve it. i am using framework 1.1

              N Offline
              N Offline
              NassosReyzidis
              wrote on last edited by
              #6

              justintimberlake wrote:

              how can i convert mm/dd/yyyy hh:mm date format to current computer date format

              string your_string_XML_Date =your_XML_Date.ToString(CultureInfo.CurrentCulture); string currentDateTime = DateTime.Now.ToString(CultureInfo.CurrentCulture); `Hope that helped Nassos GanDad `

              1 Reply Last reply
              0
              • J justintimberlake

                if my date time format is mm/dd/yyyy i.e in xml file and current computer date time format is mm-dd-yyyy can i convert my datetime string to new date time or is it that i have to parse individually year month date hour and minute and then compare

                K Offline
                K Offline
                ken tachyon
                wrote on last edited by
                #7

                I tried to reply to your email but had a display name problem and could not. If you are still having problems send an email to this message giving me a sample of the code you are having the problem with. I will be able to look at it and respond to you then.

                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