How to get the current date and time of the device

How to get the current date and time of the device? Exactly the date and time you are showing on the device.

new Date() doesn’t work?

Time zone does not match

I don’t know what you mean by “does not match”, but the Date constructor with no arguments creates a date in the local timezone:

If no arguments are provided, the constructor creates a JavaScript Date object for the current date and time according to system settings.

Nah, the time zone is fine. You’re expecting one string format, and getting another. Use date-fns or moment.js to translate all date strings into the same format.

How can I use moment?

Google and read the docs?

Don’t. It’s bloated and requires you to use dedicated objects that are not worth creating.

Thank you for the unhelpful answer

You are interacting with volunteers. It is frustrating when people ask us to hold their hands and write their apps for them, when they are demonstrating zero willingness to exert even a bare minimum of effort on their own behalf. Your attitude has a major effect on people’s willingness to work with you, and lazy passive-aggressive posts like this make me, at least, lose all motivation. So good luck with your further endeavors, but I’m done dealing with you.

1 Like

If you are not going to give an answer that can help the author of the topic, do not respond.

4 Likes

I want to send an emphatic message that acting like you are makes it considerably less likely that you will receive assistance either now or in the future.

Without problems, because I saw that here it will be complicated to receive help

1 Like

If every “volunteer” had the same attitude than the one displayed here, stackoverflow and most of the forums where you can ASK and get a valid RESPONSE would be dead today…
A valid answer save time of ppl that are going to read these topics because that is exactly what they are looking for to continue working on their own stuff, in the present or in the future.

You can think or act whatever you want, but the truth is these kind of forums are made for ppl that are having a hard time dealing with developing stuff and if you are going to help them, you should help them, if you dont want to help them, then don’t. If you want to give a useless answer, its not helping at all so DONT ANSWER (you are wasting your own time making other people waste theirs).

1 Like

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)