date string needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cm9kY2hhcg==?=

    date string needed

    hey all,

    i'd like a string of today's date in the following format:
    mmddyy

    and here's how i did it:
    String directoryName = DateTime.Now.Mo nth.ToString() +
    DateTime.Now.Da y.ToString() + DateTime.Now.Ye ar.ToString().S ubstring(2);

    is there an easier way?

    thanks,
    rodchar

  • Jeff Johnson

    #2
    Re: date string needed

    "rodchar" <rodchar@discus sions.microsoft .comwrote in message
    news:408A18F1-7A4B-4A8A-B219-80844E1B55AE@mi crosoft.com...
    hey all,
    >
    i'd like a string of today's date in the following format:
    mmddyy
    >
    and here's how i did it:
    String directoryName = DateTime.Now.Mo nth.ToString() +
    DateTime.Now.Da y.ToString() + DateTime.Now.Ye ar.ToString().S ubstring(2);
    >
    is there an easier way?
    ToString("MMddy y")

    Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings for dates & times.



    Comment

    • =?Utf-8?B?cm9kY2hhcg==?=

      #3
      Re: date string needed

      thanks for the feedback,
      rod.

      "Jeff Johnson" wrote:
      "rodchar" <rodchar@discus sions.microsoft .comwrote in message
      news:408A18F1-7A4B-4A8A-B219-80844E1B55AE@mi crosoft.com...
      >
      hey all,

      i'd like a string of today's date in the following format:
      mmddyy

      and here's how i did it:
      String directoryName = DateTime.Now.Mo nth.ToString() +
      DateTime.Now.Da y.ToString() + DateTime.Now.Ye ar.ToString().S ubstring(2);

      is there an easier way?
      >
      ToString("MMddy y")
      >
      Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings for dates & times.

      >
      >
      >

      Comment

      • Peter Morris

        #4
        Re: date string needed

        Note that MM differs from mm. MM = month, mm = minute. Someone where I
        work hard coded time formats rather than using the system format (no idea
        why), but to make things worse he encoded them all hh:ss - so we had what
        looked like end times that were before start times :-)



        --
        Pete
        ====



        Comment

        Working...