datetime conversion - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

datetime conversion

havejeethavejeet Posts: 17Member
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,



  • havejeethavejeet Posts: 17Member
    Little addition to the question,

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

  • PsightoplazmPsightoplazm Posts: 332Member ✭✭
    use a date-time formatter to format and parse with:

    var format = new DateTimeFormatInfo();
    format.LongDatePattern = "yyyyMMddHHmmss";
    var time = DateTime.Now;
    var str = time.ToString("D", format);
    var time2 = DateTime.ParseExact(
  • havejeethavejeet Posts: 17Member
    Thank you very much!

Sign In or Register to comment.