S Scott H Nov 4, 2004 #2 Hi Is it a function to convert time to and from military time? Thanks Click to expand... Theres a whole bunch of things to do with time using "now" Eg. msgbox(now.ToUniversalTime) Will give you the current UTC regardless of your timezone. if you want it in 24-hour clock: format(now.ToUniversalTime,"HH:mm:ss") (captial HH for 24 hours)
Hi Is it a function to convert time to and from military time? Thanks Click to expand... Theres a whole bunch of things to do with time using "now" Eg. msgbox(now.ToUniversalTime) Will give you the current UTC regardless of your timezone. if you want it in 24-hour clock: format(now.ToUniversalTime,"HH:mm:ss") (captial HH for 24 hours)
J Jay B. Harlow [MVP - Outlook] Nov 4, 2004 #3 Al DateTime always stores "time" in 24 hour (military time) format. It just varies how you display it. As Scott suggests you can use a custom format to change how time is displayed & parsed. Const militaryTimeFormat As String = "HH:mm" ' convert to a string in military time Dim input As String = DateTime.Now.ToString(militaryTimeFormat) ' convert from a string in military time Dim time As DateTime = DateTime.ParseExact(input, militaryTimeFormat, Nothing) For details on custom datetime formats see: http://msdn.microsoft.com/library/d...s/cpguide/html/cpcondatetimeformatstrings.asp For information on formatting in .NET in general see: http://msdn.microsoft.com/library/d...y/en-us/cpguide/html/cpconformattingtypes.asp Hope this helps Jay
Al DateTime always stores "time" in 24 hour (military time) format. It just varies how you display it. As Scott suggests you can use a custom format to change how time is displayed & parsed. Const militaryTimeFormat As String = "HH:mm" ' convert to a string in military time Dim input As String = DateTime.Now.ToString(militaryTimeFormat) ' convert from a string in military time Dim time As DateTime = DateTime.ParseExact(input, militaryTimeFormat, Nothing) For details on custom datetime formats see: http://msdn.microsoft.com/library/d...s/cpguide/html/cpcondatetimeformatstrings.asp For information on formatting in .NET in general see: http://msdn.microsoft.com/library/d...y/en-us/cpguide/html/cpconformattingtypes.asp Hope this helps Jay