Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gianmarx's avatar

manage timezones JS difference of two hours

frontend side I send axios this date away:

Mon Jun 13 2022 18:29:00 GMT+0200 (Ora legale dell’Europa centrale)

because the backend side saves me the usual one as follows:

2022-06-13 16:29:00

I wish he would save me 18:29 and not 16:29

unfortunately there are two hours of difference I tried with toString () etc. i have no idea how to fix.how can i handle this? i can't install libraries like moment.js

0 likes
2 replies
vincent15000's avatar

You have already posted this in another post, I have answered, didn't it help you ?

gianmarx's avatar

@vincent15000 I solved as follows:

	return new Date(year, month - 1, day, hours, minutes, seconds).toString().slice(0, 24);
1 like

Please or to participate in this conversation.