BookmarkSubscribeRSS Feed

JMP Time Formatting 12 v 24 hr control

Please allow users to select the time format (12 vs 24 hour) directly.


time = today(); //3619617166
formattedTime = format(time, "m/d/y h:m:s");
print(formattedTime);  //"09/12/2018 5:12:46 PM"
//What user wants: "09/12/2018 17:12:46"


m/d/y/ H:m:s (capital H to denote 24 hours -- common in other languages)

format(time, "m/d/y h:m:s", 24) - allow it to be specified in the format function, similar to Hour() function


There's some cryptic notes in the Scripting Guide that suggest the format() function chooses 12hr or 24hrs based on the computer settings, which means scripts would end up breaking on some users computers and would be difficult troubleshoot.

Tracking Number:

Defect ID:

Community Trekker

I propose taking this a step further and allowing the user to specify any format.  The default behavior of format would be something like this:


Names default to here(1);
time = 3619617166;
pad = function( {x}, if(x < 10, "0" || char( x ), char( x )));

formatdatetime = function({time, pattern, prepend=""},
		prepend || "H", pad(hour(time, 24)),
		prepend || "h", pad(hour(time, 12)),
		prepend || "M", pad(minute(time)),
		prepend || "S", pad(second(time)),
		prepend || "m", pad(month(time)),
		prepend || "d", pad(day(time)),
		prepend || "y", char(year(time)),
		prepend || "AP", char(if(hour(time)==24, "AM", if(hour(time, 24)>11,"PM","AM"))),
		// the rest of the formatting options..Month name, 
		// short month name, hours without padding, etc

formatdatetime(time, "m/d/y h:M:S AP");
// 09/12/2018 05:12:46 PM

formatdatetime(time, "ymd_HMS");
// 20180912_171246

formatdatetime(time, "hour = %h, minute = %M", "%")
// hour = 05, minute = 12
Super User

Yes I agree, if they will update the format() function it would be nice for them to go all out and make it as robust as possible.


Some useful links on time formatting:

Community Member

I've given the timestamp subject much thought as it impacts global 24 hour operations.  Because of differing local conventions (month first or day first), use of digits for day and month becomes ambiguous!  Therefore I strongly prefer the use of Alpha Mon for month.  Adding this thought to the nice time formatting suggestions above, I would like to see:

//What user wants: "12Sep2018 17:12:46"        //For example: This preferred global 24 hour format timestamp is available as "PI Time format" in OSISoft's leading PI historian.


JMP Pro 14.1 comes pretty close now with ddMonyyyy:h:m:s, but the :h is very hard to see and interpret, and a colon before a time is just "weird".  Either the capital H or dbl-lower-case hh would be more clear.