Jump to content
Sign in to follow this  
madsovenielsen

Converting Time to 12 hour format

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

Edited by madsovenielsen

Share this post


Link to post
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;}

Share this post


Link to post
Share on other sites

Actually, you'll also have to test for 0 and return 12 in that case.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...