Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Force 24 hours datetime format

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hvj@paralax.nl - 20 Sep 2007 11:10 GMT
Hi,

I am using DateTime.Now.ToString("yyyyMMddThhmmss"), but time is
displayed in 12-hours format. How can I force .NET to display 24 hours
format? Can I do something with the CultureInfo of the current thread.
I do not want it to be dependent of the settings of the computer.

Any help appreciated.

Regards,
Henk
Ben Schwehn - 20 Sep 2007 11:32 GMT
On Thu, 20 Sep 2007 03:10:54 -0700, hvj wrote:

> Hi,
>
> I am using DateTime.Now.ToString("yyyyMMddThhmmss"), but time is
> displayed in 12-hours format. How can I force .NET to display 24 hours
> format? Can I do something with the CultureInfo of the current thread. I
> do not want it to be dependent of the settings of the computer.

use HH instead of hh
hvj@paralax.nl - 21 Sep 2007 06:45 GMT
> On Thu, 20 Sep 2007 03:10:54 -0700, hvj wrote:
> > Hi,
[quoted text clipped - 5 lines]
>
> use HH instead of hh

Thanks! I'm using it to name a file, so I can't include ':'.
Ben Schwehn - 20 Sep 2007 11:55 GMT
On Thu, 20 Sep 2007 03:10:54 -0700, hvj wrote:

> I am using DateTime.Now.ToString("yyyyMMddThhmmss"), but time is

Also, if you're trying to format to ISO 8601 (I assume this because of
the 'T' separator), the format you're using is incorrect. Correct format
is for exampple:

1997-07-16T19:20:30

you can also use  XmlConvert.ToString(dateTime,
XmlDateTimeSerializationMode.XXX);

to format to ISO 8601

Ben

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.