@evokegroup/dateformat

1.0.1 • Public • Published

@evokegroup/dateformat

Adds date string formating to the Date prototype

Date.MonthNames

Array of month names in english

Date.MonthIndexes

Maps month names to the numeric month

Date.DayNames

Array of day names in english

Date.DayIndexes

Maps day names to the numeric day

Date.prototype.toStringFormat(formatString, makeUTC)

Outputs a Date into a string of given format

Parameters

Parameter Type Default Description
formatString string The string format. See Format String section for details.
makeUTC boolean false Output the date string as UTC

Format String

String Description
d The day of the month, from 1 through 31
dd The day of the month, from 01 through 31.
ddd The abbreviated name of the day of the week.
dddd The full name of the day of the week.
f The tenths of a second.
ff The hundredths of a second.
fff The milliseconds.
h The hour, using a 12-hour clock from 1 to 12.
hh The hour, using a 12-hour clock from 01 to 12.
H The hour, using a 24-hour clock from 0 to 23.
HH The hour, using a 24-hour clock from 00 to 23.
m The minute, from 0 through 59.
mm The minute, from 00 through 59.
M The month, from 1 through 12.
MM The month, from 01 through 12.
MMM The abbreviated name of the month.
MMMM The full name of the month.
s The second, from 0 through 59.
ss The second, from 00 through 59.
t The first character of the AM/PM designator.
tt The AM/PM designator.
yy The year, from 00 to 99.
yyyy The year as a four-digit number.

Usage

require('@evokegroup/dateformat');
const date = new Date('7/8/2020 14:43');
console.log(date.toStringFormat('MMMM d, yyyy h:mm tt')); // Expected output: July 8, 2020 2:43 PM

Date.prototype.toUTCStringFormat(formatString)

Outputs a UTC Date into a string of given format. See Date.prototype.toStringFormat

Readme

Keywords

none

Package Sidebar

Install

npm i @evokegroup/dateformat

Weekly Downloads

4

Version

1.0.1

License

ISC

Unpacked Size

9.2 kB

Total Files

3

Last publish

Collaborators

  • ybevoke
  • jtsuyuki
  • evokejames
  • evoke-cjamodeo