dontbecypher16 / Portals-Mirrors

https://gentle-escarpment-27252.onrender.com
0 stars 0 forks source link

Format dates and datetimes in user's locale #1

Open tim-schilling opened 2 years ago

tim-schilling commented 2 years ago

The timestamps for posts (example) are currently showing the full timestamp: "Mon Oct 25 2021 11:50:57 GMT+0000 (Coordinated Universal Time) " It's likely more useful to have the date formatted in the user's locale such as "Oct 25, 2021 11:00am"

Off the top of my head here are two popular packages to help, moment and date-fns. To integrate them, here's a SO answer that shows how to add a helper to handlebars which creates a moment instance, then renders it as a string.

dontbecypher16 commented 2 years ago

I remember glancing over the section on helpers in the handlebars docs. I was trying to format it right in the view and had gave up after a while. Will definitely try to implement this later tonight.