Home > Forums > C# >


How to convert a Time in 24 hours format?

Posted by Raja under C# on 7/22/2009 | Views : 88582 | Status : [Member] | Replies : 3
I have to write current time in 24 hours format in C#, how to do that?

Thanks

Regards,
Raja, USA



Responses

Posted by: Poster on: 7/22/2009 [Member] Starter
See following example

DateTime d = DateTime.Now;

// 12 hour format
Response.Write(d.ToString("hh:mm") + " | " );

// 24 hour format
Response.Write(d.ToString("H:mm"));


so instead of h write capital H and time will be converted in 24 hours format.

Hope this helps.

Raja, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Webmaster on: 8/26/2009 [Administrator] HonoraryPlatinum
Thanks Poster for helping the visitors.

Regards,

Best regards,
Webmaster
http://www.dotnetfunda.com

Raja, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Raja on: 8/26/2009 [Member] Starter
Thanks Webmaster. Its my pleasure to help the visitors.

Thanks

Regards,
Raja, USA

Raja, if this helps please login to Mark As Answer. | Alert Moderator
 

  Have you tried Aspose: http://aspose.com/file-tools

Login to post response