Skip to end of metadata
Go to start of metadata

Description

Loftware does not have the ability to manage time stamps.  Our date/time data can not be manipulated as a time function because our data has no formatting and is handled as simple text.  Through the use of JavaScript time data can be manipulated.  The attached sample shows how date time data can be pulled from the system without a date/time field an then be manipulated and printed in a different format on the label

Solution

The script in the sample pulls in the system date, adds 3 hours to it, and then prints it on the label in the format defined by the system in the Region and Language | Formats settings.

Requirements

Loftware version 9.5.0 or higher, and an understanding of Java Script language

How to Implement the Solution

Here is the script used in the sample label attached.

Time Handling
var jdate=new Date(); // returns current date 
label.fields.field.(@name=='RawDate').@data=jdate; 
var jtime=jdate.getTime(); // changes date to miliseconds since 1/1/1970 00:00:00 
label.fields.field.(@name=='JavaTime').@data=jtime; 
var newtime=jtime+10800000;  // add 3 hours (in milliseconds) 
label.fields.field.(@name=='TimePlus3').@data=newtime; 
var newdate=new Date(newtime); // change back to date 
label.fields.field.(@name=='AdjustedDate').@data=newdate; 
newdate=newdate.toLocaleTimeString(); // change date to time using system preferences
//output to label 
label.fields.field.(@name=='AdjustedTime').@data=newdate;

Result

The output result is the current time plus 3 hours and displayed in format:  h:mm:ss PM/AM

 

 

Article Number

 2013008

Versions

 LPS 9.5.3 and higher

Environment

All supported installation environments.