Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomkp/dates.js

Simple javascript date parser / formatter
https://github.com/tomkp/dates.js

Last synced: about 1 month ago
JSON representation

Simple javascript date parser / formatter

Awesome Lists containing this project

README

        

# Dates.js - parsing & formatting dates using regexs

Simple javascript date parser / formatter.

Minifies to < 3k.

[Mocha tests](https://github.com/tomkp/dates.js/blob/master/test/dates_tests.js)

## Examples

### Parsing a date

```Dates.parse("12/03/2009 18:02", "dd/MM/yyyy HH:mm");```

### Formatting a date

```Dates.format(new Date(2010, 3, 14, 18, 02, 39, 123), "yyyy-MM-ddTHH:mm:ss.SSS");```

### Formatting

```y```: Year eg: ```1996```, ```96```

```M```: Month in year eg: ```July```, ```Jul```, ```07```

```d```: Day in month eg: ```10```

```E```: Day in week eg: ```Tuesday```, ```Tue```

```H```: Hour in day (0-23) eg: ```9```

```m```: Minute in hour eg: ```30```

```s```: Second in minute eg: ```55```

```S```: Millisecond eg: ```978```