Unable to convert milliseconds to datetime format

Dineshdmkk18
Tera Contributor

Hello Team,

 

I'm using the below glideschedule API to get the next window time of the maintenance schedule. As the API is providing the results in milliseconds. I'm converting the same to datetime format using the below script.

 

var schedule = new GlideSchedule('e7d33c2bdbf4029055ee4098139619ee');
var whenNext = schedule.whenNext();
gs.info('WN '+whenNext);

var gdt = new GlideDateTime();
gdt.setNumericValue(whenNext);
gs.info('Epo '+gdt.getDisplayValue());

 

I'm getting the below result. However this is not correct. Am I missing something? Please advise on the same.

 

*** Script: Epo 02-01-1970 20:47:13

I'm expecting the datetime result in current/future datetime.

 

Thanks,

DC

1 ACCEPTED SOLUTION

Shubham26
Tera Guru

Hi @Dineshdmkk18 

 

Can you please try with below code.

 

var schedule = new GlideSchedule('e7d33c2bdbf4029055ee4098139619ee');
var whenNext = schedule.whenNext();
gs.info('WN '+whenNext);

var gdt = new GlideDateTime();

gdt.add(whenNext)
gs.info('Epo '+ gdt.getValue());

 

Please mark helpful or accept answer if provided info works for you.

 

Thank You.

 

Regards,

Shubham Gupta

View solution in original post

4 REPLIES 4

Anubhav24
Mega Sage
Mega Sage

Hi @Dineshdmkk18 ,

Can you try after specifying the timezone as well in the whennext function like below :

var glideSchedule = new GlideSchedule('08fcd0830a0a0b2600079f56b1123456', 'UTC');

 

Also if the GlideSchedule object is within the schedule it might not return a meaningful value.

 

Please mark helpful/correct if my response helped you.

Thanks @Anubhav24 

 

It doesn't make any difference in the solution.

Shubham26
Tera Guru

Hi @Dineshdmkk18 

 

Can you please try with below code.

 

var schedule = new GlideSchedule('e7d33c2bdbf4029055ee4098139619ee');
var whenNext = schedule.whenNext();
gs.info('WN '+whenNext);

var gdt = new GlideDateTime();

gdt.add(whenNext)
gs.info('Epo '+ gdt.getValue());

 

Please mark helpful or accept answer if provided info works for you.

 

Thank You.

 

Regards,

Shubham Gupta

Thank you @Shubham26