ticktick-wrapper icon indicating copy to clipboard operation
ticktick-wrapper copied to clipboard

Shows incorrect date

Open arionrefat opened this issue 3 years ago • 4 comments

This is date I have choosen. image and this is date it shows from the api image

arionrefat avatar Jan 23 '22 07:01 arionrefat

Hi!

This is the correct date stored in TickTick's servers.

I'm guessing you live somewhere on a GMT+6 timezone, and when TickTick creates the due date on your browser, it uses the the date on 12AM on local time, and then converts it to UTC.

This also happened with me, I recently moved from Brazil (GMT-3) to Vancouver (GMT-8) and all of my tasks were suddenly due one day earlier on the browser, because now it was interpreting all those tasks created in the wrong timezone.

mikaelmello avatar Jan 23 '22 18:01 mikaelmello

Ahh, thank you for your reply. Got it. Any idea how to fix this? Or do I have to add +6 manually

arionrefat avatar Jan 23 '22 18:01 arionrefat

I'd recommend that you add a date library on your project which will read the dates interpreting them as UTC and convert them to your local timeozne.

Example using an outdated library:

let utcTime = "2015-09-13 03:39:27";
let date = moment.utc(utcTime).format('YYYY-MM-DD HH:mm:ss');

console.log(date); // 2015-09-13 03:39:27

let stillUtc = moment.utc(date).toDate();
let local = moment(stillUtc).local().format('YYYY-MM-DD HH:mm:ss');

console.log(local); // 2015-09-13 09:39:27

mikaelmello avatar Jan 23 '22 18:01 mikaelmello

Thank you for your suggestion and god bless your project, I used it in my discord bot project here. I'm a beginner, so my code is very messy needs to a lot of refractoring. I learned a lot from your project. Thank you

arionrefat avatar Jan 25 '22 08:01 arionrefat