• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Making Your Pages Dynamic > Converting Military Time to AM/PM

Converting Military Time to AM/PM

JavaScript provides the time in 24-hour format, also known as military time. Many people are unfamiliar or uncomfortable with this format, so you'll want to know how to convert it to 12-hour format. In Script 10.5, you see one way to go about the task, which needs a bit of explanation. The page we're creating uses a form containing a single text field into which we write the time, based on a function in the script. The form is controlled by two radio buttons, which let us switch the time from 24-hour format into 12-hour format. The result is shown in Figure 10.5.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint