Jump to content

Converting Time to 12 hour format


madsovenielsen

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...