Hi,
Howto convert this string in to Date?
1515769353
Source is the Nokia Health Api.
Once AM says "can not convert value 'null' to number"
next time i tried
"Unparseable date".
What's the right syntext?
Tried:
getDate(variable, "yyyy.MM.dd");
getDate(variable,dateformat,"dd.MM.yyyy HH:mm:ss");
With and without multiplication *1000 to convert it to ms.
Also tried "toNumber", no go.
Anyone?
EDIT:
OK, brrrrrrr
think i have do the multiplication with 100 instead of "1000".
time=1515769353*1000;
time_formatted = "{time, dateformat, dd.MM.yyyy HH:mm:ss}";
this do the job.
unix to date/time
Moderator: Martin
- schuster666
- Posts: 52
- Joined: 13 Nov 2013 14:03
- Location: Germany / Neuss
unix to date/time
-- the world would be better without people--
-- but boring --
-- but boring --
Re: unix to date/time
The time_formatted you get after using your code above is a string, not a datetime. You can't add it as usual. Be careful of logic flaw trap when dealing with time in string format. It is preferred to always store time in the datetime format, and convert to string only at the last step before displaying it.
1515769353 is seconds, means just use s in the checking string.
To use miliseconds, use uppercase S.
I don't know if the API give you the correct timezone. If it gives based on UTC, you can add/minus your timezone hours to it. Example for UTC+7, add 7 hours.
While if you use time_formatted in string format, the addHours() will throw error exception.
1515769353 is seconds, means just use s in the checking string.
Code: Select all
variable = 1515769353;
time = getDate(variable, "s");
I don't know if the API give you the correct timezone. If it gives based on UTC, you can add/minus your timezone hours to it. Example for UTC+7, add 7 hours.
Code: Select all
variable = 1515769353;
timez = addHours(getDate(variable, "s"), 7);
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.