2

I developed node js services with Sequelize with MySQL Everything working good. I am storing data in DB with date and time with service but if I get the same data with service, node js automatically converting time (a wrong format which is not in the database), I want same time which is present in the database. to solve this issue I set the timezone in services and in the database but none of them is working. can anyone provide me with the solution.

1
  • post your code. Commented Dec 7, 2018 at 6:38

2 Answers 2

1

That's not the issue of node js , Sequelize by default gives the time in UTC , so that date time will be correct

Check : Just compare your date time with UTC , and check is that you are getting.

Solution : So what you can do is , just convert returned date and time to your timezone and you are good to go.

And that's a good practice if you are using UTC everywhere , you can get benefits when you are getting / showing in many countries.

Sign up to request clarification or add additional context in comments.

Comments

1

suggestion

you could include time format function in mysql for example

SELECT TIME_FORMAT("19:30:10", "%H %i %s");

result

TIME_FORMAT("19:30:10", "%H %i %s") 19 30 10

ref

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.