1.0.24 • Published 6 years ago

date_time_formatter v1.0.24

Weekly downloads
55
License
GNU
Repository
-
Last release
6 years ago

date_time_formatter

Installation

$ npm install date_time_formatter

Usage

var dateTimeFormatter = require('date_time_formatter');
var now = new Date();

dateTimeFormatter.formatDate(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
// Saturday, June 9th, 2007, 5:46:21 PM


dateTimeFormatter.formatDate(now, "W");
// 42

dateTimeFormatter.formatDate(now,"N");
// 6

Format options

OptionDescription
dDate
ddDate with leading zero
dddFirst three letters of day of week
ddddFull name for day of week
mMonth
mmMonth with leading zero
mmmFirst three letters of the month.
mmmmMonth's full name.
yyYear as last two digits
yyyyFull Year.
hHours (12-hour clock).
hhHours with leading zero (12-hour clock).
HHours (24 hour)
HHHours with leading zero (24 hour)
MMinutes
MMMinutes with leading zero
NDay of Week. Ex. Monday is 1
oTime zone offset string
sSeconds
ssSeconds with leading zero
Sst, nd, rd, or th
l3 digit Milliseconds
L2 digit Milliseconds
ta or p.
ttam or pm.
TA or P.
TTAM or PM.
WCurrent week in the year
...Surround text with this to print directly in the string

Localization of text

You can use the following to change names for days and months for your area.

dateTimeFormatter.i18n.texts = {
    longDayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
    shortDayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
    longMonthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
    shortMonthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}
1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago