I am pulling data from a table that uses unix time and want to convert the unix time to a format that I can then plugin to the DATETIME column I have in Servoy.
Here’s my conversion method, but I get an error when I try to set it in a DATETIME column in Servoy.
function unix_epoch_to_date()
{
// converts date to unix epoch
if (arguments[0] === null || arguments[0] === '')
{
return;
}
var myDate = new Date( arguments[0] *1000);
var thyTime = myDate.toTimeString()
var thyDate = myDate.toDateString()
var thyFinalDate = thyDate + " " + thyTime
return thyFinalDate
}
At first glance I’d say that you are using 3 equal signs (===) instead of 2 (==) in your if statement, try to turn the debugger on and see if the code is actually executed.
I’m not sure why you make it a string in the first place, but I think you can just use this instead:
function unix_epoch_to_date()
{
// converts date to unix epoch
if (arguments[0] === null || arguments[0] === '')
{
return;
}
var myDate = new Date( arguments[0] *1000);
return myDate;
}