localizationSystem returning wrong time
global.localizationSystem.getTimeFormatted
is returning UTC time.
This happens both in Lens Studio on the mac, or testing a lens on
mobile (iphone XR, with privacy settings allowing Snapchat to use
my location). I'm in Pacific Standard Timezone, so at 9:30PM
Saturday, getTimeFormatted is returning 4:30AM Sunday, which is
UTC. Is there an additional parameter I need to pass in order to
get the correct local time?
Thanks for your help.
hi Michael French
you can simply use a screen text and in Dynamic text there is the local time and date and a lot of helpful things
and for doing it with JS
to get the day
var currentDate = new Date(); print("Today is: " + global.localizationSystem.getDayOfWeek(currentDate));
and to get time
var currentDate = new Date();
print("The current time is: " + global.localizationSystem.getTimeFormatted(currentDate));
Please Check the guide of LocalizationSystem
i hope that helped, if you need any help just let us know
Cheers.
Hi and thanks very much for the response.
Yes dynamic text shows the correct localized date / time, but I'm accessing date and time from javascript (as described in LocalizationSystem in the api) which apparently should return localized time, but I'm only getting UTC time (7 hours ahead of my time zone). For example:
This does not return the localized time; it returns UTC time, which is why I wondered if there was an additional parameter I was missing or something.
But for the time being I can just pull the string from dynamic text and use that in my code, since the dynamic text version seems reliable.