datetime conversion

Hi All,

I want to convert current datetime (differs in format depending regional setting) into 20090622172120 format.
How do I do that? I want solution that work with any regional setting.

many thanks,

Jeet

Comments

  • Little addition to the question,

    I also required to convert that format back in original string. Please suggest.

    thanks
    Jeet
  • use a date-time formatter to format and parse with:

    [code]
    var format = new DateTimeFormatInfo();
    format.LongDatePattern = "yyyyMMddHHmmss";
    var time = DateTime.Now;
    var str = time.ToString("D", format);
    MessageBox.Show(str);
    var time2 = DateTime.ParseExact(
    str,
    "D",
    format);
    MessageBox.Show(time2.ToString());
    [/code]
    ><//~Psightoplasm`~
  • Thank you very much!

    Jeet
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories