Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Help With date/time


Level 2

In need a time box that will convert “8pm” or “8 pm” or “8:00pm” or “8:00 pm” to military time.  I tried some javascript on exit but it doesn’t quite work.

if (this.rawValue.length <= 5){

            var space = this.rawValue.indexOf(" ")

            this.rawValue = this.rawValue.substr(0,space) + ":00" + this.rawValue.substr(space,10)


2 Replies


Level 10

This is not a trivial problem. I started coding some regular expressions to parse the date string but I quickly realized how difficult it is. The attached contains some of that code. I ended up using drop downs and a radio button to calculate military time (I think it works correctly). It is easier (somewhat).


// form1.page1.subform2.militaryTime::calculate - (JavaScript, client)

if (!(form1.page1.subform2.hrs.isNull || form1.page1.subform2.mins.isNull || form1.page1.subform2.meridiem.isNull)) {

  var hrsStr = form1.page1.subform2.hrs.rawValue;

  if (form1.page1.subform2.meridiem.rawValue == "AM") {

    if (hrsStr == "12") {

      hrsStr = "00";



  else {

    var hrs = parseInt(hrsStr);

    if (hrs == 12) {

      hrs = 0;


    hrs = hrs + 12;

    hrsStr = hrs.toString();


  this.rawValue = hrsStr + form1.page1.subform2.mins.rawValue;




Level 2

It’s a time sheet, the user enters start time and end time.  I need it to be in military time.  There is no room to change the form that is why I need the user to enter their start time.  And when they go onto another box the time they enter will display military time.  So I need to account for “8pm” or “8 pm” or “8:00pm” or “8:00 pm”, for late times as well eg. 8:04.