macdate
v1.1.10
Published
Mac / iOS style date formatting
Downloads
4
Maintainers
Readme
MacDate - Format dates like Mac / iOS
Ya know how dates are always very human friendly on Apple devices? Like, if the date is today, it just says, "Today". If the date is yesterday, it just says, "Yesterday". And dates previous to yesterday show the full date formatted like, "June 3, 2021".
Times are also formatted in a very clean way like, "11:36 AM". And when dates and times are used together, they look like, "Yesterday at 12:30 PM".
So that's all this does. It just formats a JS Date object as either a "day", "time", or "dayAndTime". If no date object is passed in, then a fresh Date.now()
will be used.
How to use
npm install macdate
import macdate from 'macdate';
macdate.day(); // ex: 'Today'
macdate.time(); // ex: '12:31 PM'
macdate.dayAndTime(); // ex: 'Today at 12:31 PM'
macdate.dayAndTime(dateObj); // ex: 'Yesterday at 10:02 AM'
macdate.dayAndTime(dateObj); // ex: 'June 3, 2021 at 9:17 PM'