Javascript Date Conversation Timezone hack

Mudaser Ali
Dec 9, 2022

--

Suppose you are storing only date in database with format YYYY-MM-DD and when trying to use that date on frontend sometimes returns previous date instead of passed date due to timezone conversion

Date Conversion -1 Day

There is very simple fix to this problem just add a space at the end of the date Date method will automatically convert it into a start day of the month

Actual Date

Enjoy!

--

--

Mudaser Ali

{ name: Mudaser Ali aka SMAK, skills: NoBody is pErfect i M nObOdy, passion: {love: [programming, photography]} }