.NET General

Moderators: None (Apply to moderate this forum)
Number of threads: 749
Number of posts: 1301

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
datetime conversion Posted by havejeet on 22 Jun 2009 at 11:10 PM
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

Report
Re: datetime conversion Posted by havejeet on 23 Jun 2009 at 5:06 AM
Little addition to the question,

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

thanks
Jeet
Report
Re: datetime conversion Posted by Psightoplazm on 23 Jun 2009 at 7:43 AM
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);
            MessageBox.Show(str);
            var time2 = DateTime.ParseExact(
                str,
                "D",
                format);
            MessageBox.Show(time2.ToString());

></\/~Psightoplasm`~
Report
Re: datetime conversion Posted by havejeet on 24 Jun 2009 at 12:21 AM
Thank you very much!

Jeet



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.