pjs.timestamp()

The pjs.timestamp() API converts an expression to a timestamp, or returns the current date & time as a timestamp if no parameters are passed to it. 

Parameters


  • Field or expression (optional)
  • Format or Fractional seconds (optional) - format can be *iso or *iso0
  • Fractional seconds (optional)

Return Value


A timestamp value

RPG Equivalent


%TIMESTAMP()

What's the difference between *iso and *iso0?

*iso is the default timestamp format. *iso0 is for indicating there are no separators in the timestamp.

Examples


pjs.define("Kstamp", { type: 'timestamp', initValue: pjs.timestamp('2019-12-31-12.34.56.789000') });
timest = pjs.timestamp('1960-09-29-12.34.56.12300', "*iso");
data = pjs.char(timest);

More Examples


If you need to convert a string with a date value in it, you need to use this in conjunction with pjs.toDate(). Below is an example: 

timest = pjs.timestamp(pjs.toDate('2001-03-05'));   //The date string value is converted to a date first, and then to a timestamp.