Tardis JS an open source JavaScript Date library for parsing, formatting and processing. A simple, light weight and easy to implement module that you can use in your JS appication or website.
Via NPM: npm i lbx-tardis
or
Include tardis.js in your build directory or link to it directly
<script type="text/javascript" src="tardis.js"></script>
Download tardis.js or tardis.min.js
Clone it on GitHub
const getDate = tardis.dateparts() // { year: 119, month: 6, day: 29, hour: 13, min: '04', sec: '12', fullYear: 2019, shortYear: '19', wordYear: 'two thousand and nineteen', fullMonth: 'June', shortMonth: 'Jun',....} const getISO = tardis.ISO() // 2019-06-29 const getTimeStamp = tardis.patterned(1133481000, 'M/DD/YYYY - H:I:s TT tt'); // { pattern: '12/02/2005 - 18:50:{{26}} PM pm', time: 1133481000 } const getTime = tardis.patterned('2019-06-29T17:26:43', 'M/DD/YYYY - HH:II:SS tt'); //{ pattern: '6/30/2019 - 18:26:43 pm', time: '2019-06-29T17:26:43' }
The Date Object
{ }
By using a simple mask you can create a unique time format to meet all of your needs. Simply by invoking the patterned method, passing in a time stamp and defining a filter pattern. If you do not supply a time stamp the method will assume you want the current time and return date.Now(). The returned object ({pattern: pattern, time: theTime}) with have your patterned string and the time as a unix timestamp should you need to reuse it.
Tardis JS has several prebuilt filter patterns for the most commonly used time formats. Simply, call the method of the preset format you want and set a timestamp. If you do not supply a timestamp, date.Now() will be returned.
tardis.ISO({date}) // 2019-06-30 tardis.ShortDate({date}) // 06/30/2019 tardis.LongDate({date}) // Jun 30 2019 tardis.DayMonthDate({date}) // Thursday, Decemeber 1, 2005 tardis.MonthDateTime({date}) // Decemeber 1, 2005 18:50 tardis.MonthDateTime12({date}) // Decemeber 1, 2005 6:50 PM tardis.MonthDate({date}) // Decemeber 1, 2005 tardis.TimeOfDay({date}) // 14:00:53 tardis.TimeOfDay12({date}) // 2:01:31 PM tardis.Year({date}) // 2019 tardis.Month({date}) // June tardis.Day({date}) // Sunday
© Logikbox 2024
Privacy Policy