How to get date format using 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.

Comments

Popular posts from this blog

CSP-102547 Patch Upgrade Experience VMware Identity Manager 3.3.7 & Aria Suite Lifecycle 8.18.0 (Patch 5 → 7)

Bulk Import DFW Rules to NSX-T using Aria Automation

VCF 9 Automation vs Aria Automation 8.x (Part 1)