Hi.
I want to format some dates in my Express views.
First of all, my employer, i.TV, has a DateTime library that we wrote that is alright:
https://gist.github.com/1125717
But I was hoping this would be something that's more in the view layer than than in the model/controller level.
Here are some libraries and functions that do some version of that:
http://www.datejs.com/
https://github.com/Flamefork/underscore.date
https://github.com/cdcarter/commonjs-date-formatting
http://timeago.yarp.com/
However, none of them did what I wanted. Here is one that did:
http://ejohn.org/blog/javascript-pretty-date/
This is what I did to make it work in my express views:
Hey Jamund,
ReplyDeleteHere's a modification to John's script that you might like:
https://github.com/zachleat/Humane-Dates
You can check out the tests to see if it meets your needs:
https://github.com/zachleat/Humane-Dates/blob/master/src-test/humaneDatesTest.js
@zachleat, neat thanks!
ReplyDeleteI wrote a library for date modification called underscore.date that does this same thing. I handles parsing, formatting, and timeago.
ReplyDeleteIt also handles i18n, so you can customize all the strings.
https://github.com/timrwood/underscore.date
@washwithcare. your library looks awesome too!
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete