Skip to content

Formatting Date to String and parsing String to Date module for Node.js, RequireJS, and browser.

License

Notifications You must be signed in to change notification settings

esk525/dateformat-js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dateformat.js

Formatting Date to String and parsing String to Date module for Node.js, RequireJS, and browser.

Installation

$ npm install dateformatjs

Usage

var DateFormat = require('dateformatjs').DateFormat;
var df = new DateFormat("yyyy'-'MM'-'dd' 'HH':'mm':'ss.fff' 'zzzz");
df.format(new Date());
df.parse('1981-07-04 15:02:06.050 +09:00');

Allowed specifiers

The following specifiers are defined.

Format SpecifierDescriptionExamples
7/4/1981 15:2:6.05 GMT+09:00
dThe day of the month, from 1 through 31.4
ddThe day of the month, from 01 through 31.04
dddThe abbreviated name of the day of the week.Sat
ddddThe full name of the day of the week.Saturday
fThe tenths of a second in a date and time value.0
ffThe hundredths of a second in a date and time value.05
fffThe milliseconds in a date and time value.050
FIf non-zero, the tenths of a second in a date and time value.(no output)
FFIf non-zero, the hundredths of a second in a date and time value.05
FFFIf non-zero, the milliseconds in a date and time value.050
gThe abbreviated name of period or era.AD
ggThe full name of period or era.A.D.
hThe hour, using a 12-hour clock from 1 to 12.3
hhThe hour, using a 12-hour clock from 01 to 12.03
HThe hour, using a 24-hour clock from 0 to 23.15
HHThe hour, using a 24-hour clock from 00 to 23.15
KTime zone information.UTC, Local
jJulian day of the year.025
mThe minute, from 0 through 59.2
mmThe minute, from 00 through 59.02
MThe month, from 1 through 12.7
MMThe month, from 01 through 12.07
MMMThe abbreviated name of the month.Jul
MMMMThe full name of the month.July
sThe second, from 0 through 59.6
ssThe second, from 00 through 59.06
tThe abbreviated AM/PM designator.PM
ttThe full AM/PM designator.P.M.
yThe year, from 0 to 99.1
yyThe year, from 00 to 99.81
yyyThe year, with a minimum of three digits.1981
yyyyThe year as a four-digit number.1981
yyyyyThe year as a five-digit number.01981
zHours offset from UTC, with no leading zeros.+9
zzHours offset from UTC, with a leading zero for a single-digit value.+09
zzzHours and minutes offset from UTC.+0900
zzzzHours and minutes offset from UTC.+09:00
"*", '*'Literal string delimiter.*
"", ''Double quote and single quote.", '
*Any other character.*

License

Licensed under the MIT license.

About

Formatting Date to String and parsing String to Date module for Node.js, RequireJS, and browser.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%