Hello,
I followed the tutorial : http://www.coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/
But I cannot get the current time in UTC. I tried : print( os.date("!%FT%XZ") ) but it does not work !
Any idea ?
Thanks.
Hello,
I followed the tutorial : http://www.coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/
But I cannot get the current time in UTC. I tried : print( os.date("!%FT%XZ") ) but it does not work !
Any idea ?
Thanks.
I just ran your code using command line Lua and it printed:
2013-06-09T21:28:55Z
It’s 5:28pm ET, we are in DST so 21:28 - 17:29 = 4 which is the offset between us and GMT right now. Just for fun, I actually ran it in the Corona SDK sim and got the same results (well albeit 3 minutes later). So the time printed is in UTC
Thanks for the answer.
My corona simulator (on windows) froze everytime during os.date("!%FT%XZ"). I had to kill the process.
I tried to test on my Android device (Nexus 7) and I got nothing also.
Edit 1 : I misread the part you wrote : “well albeit 3 minutes later”. So it is a bug, no ?
I can understand problems with Windows because their C library (which is where the strftime function used by os.date comes from) is still dependent on the MS-DOS/Windows date structure which is different than the Unix time format used by Mac OS-X, iOS and Android. There may be format differences. Please see:
http://msdn.microsoft.com/en-us/library/fe06s4ak%28VS.71%29.aspx
To see what is supported on Windows.
As far as the problems on Android, we need to know more about why it’s not working. Can you look at your console log on Android with “adb logcat” and maybe put a few print’s in to see what’s going on.
And the “albeit 3 minutes later” isn’t a bug. I ran the next test 3 minutes later. The difference was still the expected 4 hours.
Indeed it does not work on Windows (due to Windows) but does work on my Android device.
I made a simple test program with os.date("!%FT%XZ") and I got the expected result.
Sorry for wasting your time about that.
I just ran your code using command line Lua and it printed:
2013-06-09T21:28:55Z
It’s 5:28pm ET, we are in DST so 21:28 - 17:29 = 4 which is the offset between us and GMT right now. Just for fun, I actually ran it in the Corona SDK sim and got the same results (well albeit 3 minutes later). So the time printed is in UTC
Thanks for the answer.
My corona simulator (on windows) froze everytime during os.date("!%FT%XZ"). I had to kill the process.
I tried to test on my Android device (Nexus 7) and I got nothing also.
Edit 1 : I misread the part you wrote : “well albeit 3 minutes later”. So it is a bug, no ?
I can understand problems with Windows because their C library (which is where the strftime function used by os.date comes from) is still dependent on the MS-DOS/Windows date structure which is different than the Unix time format used by Mac OS-X, iOS and Android. There may be format differences. Please see:
http://msdn.microsoft.com/en-us/library/fe06s4ak%28VS.71%29.aspx
To see what is supported on Windows.
As far as the problems on Android, we need to know more about why it’s not working. Can you look at your console log on Android with “adb logcat” and maybe put a few print’s in to see what’s going on.
And the “albeit 3 minutes later” isn’t a bug. I ran the next test 3 minutes later. The difference was still the expected 4 hours.
Indeed it does not work on Windows (due to Windows) but does work on my Android device.
I made a simple test program with os.date("!%FT%XZ") and I got the expected result.
Sorry for wasting your time about that.