madsovenielsen Posted March 28, 2010 Share Posted March 28, 2010 Hey all.I am using the buildtin Time function in VBscript. the server im working on is set to 24 hour formatis there a function or method to convert Time output to 12 hour format ?I have found a way to convert to 24 hour format. but it seems that theres no way to format 24 hour to 12 hour format./mads Link to comment Share on other sites More sharing options...
Ingolme Posted March 29, 2010 Share Posted March 29, 2010 If the time is greater than 12, subtract 12. It's that easy.I don't know VBscript, but in Javascript it would be this simple: function from24(h) { return (h > 12) ? h-12 : h;} Or to make it easier to understand: function from24(h) { if(h > 12) { h = h - 12; } return h;} Link to comment Share on other sites More sharing options...
madsovenielsen Posted March 31, 2010 Author Share Posted March 31, 2010 Thanks. Link to comment Share on other sites More sharing options...
Ingolme Posted March 31, 2010 Share Posted March 31, 2010 Actually, you'll also have to test for 0 and return 12 in that case. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.