vRO

Date format in vRO

/** Get date **/
var date = new Date(),
yy=date.getFullYear().toString().substr(2,2);
mm=(date.getMonth() < 10 ? “0” : “”) + (date.getMonth()+1);
dd=(date.getDate() < 10 ? “0” : “”) + date.getDate();
HH=(date.getHours() < 10 ? “0” : “”) + date.getHours();
MM=(date.getMinutes() < 10 ? “0” : “”) + date.getMinutes();

Example:
var myTimestamp = System.getCurrentTime();
var myDate = new Date();
myDate.setTime(myTimestamp);
System.log(“getYear from DateObject: “+(myDate.getYear()+1900));
System.log(System.formatDate(myDate, “YYYY-MM-dd HH:mm:ss”));

/** Add Days: **/
timerDate = new Date();
System.log( “Current date : ‘” + timerDate + “‘” );
timerDate.setTime( timerDate.getTime() + (86400 * 1000) );

System.log( “Timer will expire at ‘” + timerDate + “‘” );

The preceding example JavaScript function defines a Date object that obtains the current date and time by using the getTime method and adds 86,400,000 milliseconds, or 24 hours.

Tags

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Close