I previously convert a date object to primitive value by google app script using new Date().valueOf()
.
The primitive value is 1.626139723E12.
I would like to convert back primitive value to human readable date object.
I tried: B4 => 1.626139723E12
B4.Gettime => undefined
B4.toString => 1.626139723E12
new Date(B4) => Invalid Date
B4.toLocaleString() => 1.626139723E12
B4.toUTCString() => is not a function
Utilities.formatDate(B4, "GMT", "MM/dd/yyyy-HH:mm:ss") => Exception: The parameters (String,String,String) don't match the method signature for Utilities.formatDate
Following the comment from Copper, I also try:
var scriptProperties = PropertiesService.getScriptProperties();
var PropName = "Last time"
var LastForwardTime = scriptProperties.getProperty(PropName);
function test(){
Logger.log(LastForwardTime);
const dt = new Date(LastForwardTime);
Logger.log(dt)
}
The log is as follows:
1:38:09 PM Notice Execution started
1:38:11 PM Info 1.626139723E12
1:38:11 PM Info Thu Jan 01 08:00:00 GMT+08:00 1970
1:38:09 PM Notice Execution completed
It is not working properly.
So is there a way can convert primitive value back to Date object in google app script.