Announcing the Global SNUG Board of Directors. Learn more here
on 02-07-2019 04:34 AM
Convert epoch to date / Convert date to epoch
function round function(value, digits){
return (Math.round((value*Math.pow(10,digits)).toFixed(digits-1))/Math.pow(10,digits)).toFixed(digits);
}
function convertDateToEpoch(vDate)
{
epoch = '';
vDateTmp = new GlideDateTime(vDate).getNumericValue() / 1000;
epoch = this.round(vDateTmp, 0);
return epoch;
}
function convertEpochToDate (vepoch){
var gdt_end = new GlideDateTime();
var vendDate = vepoch * 1000;
gdt_end.setNumericValue(Math.round(vendDate ,0));
return gdt_end;
}
Scoped GlideDateTime API Reference
Was useful, please leave your feedback!
Thanks for sharing.