Date object is not recognizing getTime() function in PAM
search cancel

Date object is not recognizing getTime() function in PAM

book

Article ID: 266628

calendar_today

Updated On: 10-19-2023

Products

CA Process Automation Base

Issue/Introduction

The JavaScript getTime() function is not being recognized in Date objects.

Error:

TypeError: Cannot find function getTime in object

Failed to execute code

Environment

Release : 4.4

Cause

Error in the Javascript code

Resolution

Use the following approach to work with getTime() function

var d = new Date("2021-06-10T10:00:00Z");
var gettime = d.getTime();
Process.date1 = gettime 

 

 

In addition, the following information will be helpful to work with dates:

//Date(year, month, day, hours, minutes, seconds, milliseconds);
var d = new Date("2021-01-01T10:30:00Z");
//The getDate() method returns the day of the month (from 1 to 31) for the specified date.
var day = d.getDate();
//Returns the day of the week (from 0-6)
var weekday = d.getDay();
//     Returns the month (from 0-11)
var month = d.getMonth();
//Returns the year
var year = d.getFullYear();
//     Returns the hour (from 0-23)
var hour = d.getHours();
//Returns the minutes (from 0-59)
var minutes = d.getMinutes();
//Returns the seconds (from 0-59)
var seconds = d.getSeconds();
//     Returns the milliseconds (from 0-999)
var milliseconds = d.getMilliseconds();
//Returns the number of milliseconds since midnight Jan 1 1970, and a specified date
var gettime = d.getTime();
//Returns the time difference between UTC time and local time, in minutes
var timezone = d.getTimezoneOffset();
//Return the number of milliseconds between a specified date and midnight January 1 1970:
var utc = Date.UTC(year, month+1, day);

Process.Date = d;
Process.dayy = day;
Process.month = month;
Process.year = year;
Process.hour = hour;
Process.minutes = minutes;
Process.seconds = seconds;
Process.milliseconds = milliseconds;
Process.weekday = weekday;
Process.gettime = gettime;
Process.timezone =timezone;
Process.utc = utc;

Reference:

https://community.broadcom.com/communities/community-home/librarydocuments/viewdocument?DocumentKey=9bc354b8-3fcd-46ee-8c19-90be0fa42a12