angular-dateParser

A simple parser that converts date and time strings into Date object

Angular Core Dependency: ^1.6.4

Module License: MIT

Added by: Sam Deering

GitHub

Repository

dnasir/angular-dateparser

Stats

Stars: 39

Watchers: 39

Forks: 27

Module Description

Angular DateParser

A simple parser that converts date and time strings into JavaScript Date objects.

Demo

Prerequisites

  1. Angular 1.0.5+

Installing

bower install angular-dateParser --save

or

npm install angular-dateParser --save

Usage

Simply include the parser file, add it as a dependency and call it like so:

$dateParser(string, format)

The first parameter is the date and time string you wish to convert to a Date object, and the second parameter is the format you're using. The format is optional, so if you're using the RFC2822 or ISO 8601 date formats, you're more or less safe, as the parser will simply pass the string to the Date constructor.

Expected return value is a JavaScript Date object, or undefined if values are invalid.

Date formats

All Date formats specified in the Date filter documentation can be used, as well as custom formats. See the demo for examples.

Note: When the w or ww format strings are used, the parser will return undefined in the event the provided week number is invalid, or does not match the provided date string. It will return a valid Date object if the provided date falls within the start and end of the week for the provided week number.

Localisation

This parser depends on the $locale service to provide it with the list of formats, as well as names of months and days. To use this feature, include the locale file included in the Angular bundle.

Module stats last updated: 2017-06-30 16:00:05

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!