Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Latest commit

 

History

History

dateparser

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

The uibDateParser is what the uib-datepicker uses internally to parse the dates. You can use it standalone by injecting the uibDateParser service where you need it.

The public API for the dateParser is a single method called parse.

Certain format codes support i18n. Check this guide for more information.

uibDateParser's parse function

parameters
  • input(Type: string, Example: 2004/Sep/4) - The input date to parse.

  • format(Type: string, Example: yyyy/MMM/d) - The format we want to use. Check all the supported formats below.

  • baseDate(Type: Date, Example: new Date()) - If you want to parse a date but maintain the timezone, you can pass an existing date here.

return
  • If the specified input matches the format, a new date with the input will be returned, otherwise, it will return undefined.

uibDateParser's format codes

  • yyyy(Example: 2015) - Parses a 4 digits year.

  • yy(Example: 15) - Parses a 2 digits year.

  • y(Example: 15) - Parses a year with 1, 2, 3, or 4 digits.

  • MMMM(Example: February, i18n support) - Parses the full name of a month.

  • MMM(Example: Feb, i18n support) - Parses the short name of a month.

  • MM(Example: 12, Leading 0) - Parses a numeric month.

  • M(Example: 3) - Parses a numeric month.

  • M!(Example: 3 or 03) - Parses a numeric month, but allowing an optional leading zero

  • LLLL(Example: February, i18n support) - Stand-alone month in year (January-December). Requires Angular version 1.5.1 or higher.

  • dd(Example: 05, Leading 0) - Parses a numeric day.

  • d(Example: 5) - Parses a numeric day.

  • d!(Example: 3 or 03) - Parses a numeric day, but allowing an optional leading zero

  • EEEE(Example: Sunday, i18n support) - Parses the full name of a day.

  • EEE(Example: Mon, i18n support) - Parses the short name of a day.

  • HH(Example: 14, Leading 0) - Parses a 24 hours time.

  • H(Example: 3) - Parses a 24 hours time.

  • hh(Example: 11, Leading 0) - Parses a 12 hours time.

  • h(Example: 3) - Parses a 12 hours time.

  • mm(Example: 09, Leading 0) - Parses the minutes.

  • m(Example: 3) - Parses the minutes.

  • sss(Example: 094, Leading 0) - Parses the milliseconds.

  • ss(Example: 08, Leading 0) - Parses the seconds.

  • s(Example: 22) - Parses the seconds.

  • a(Example: 10AM) - Parses a 12 hours time with AM/PM.

  • Z(Example: -0800) - Parses the timezone offset in a signed 4 digit representation

  • ww(Example: 03, Leading 0) - Parses the week number

  • w(Example: 03) - Parses the week number

  • G, GG, GGG(Example: AD) - Parses the era (AD or BC)

  • GGGG(Example: Anno Domini) - Parses the long form of the era (Anno Domini or Before Christ)

* The ones marked with Leading 0, needs a leading 0 for values less than 10. Exception being milliseconds which needs it for values under 100.

** It also supports fullDate|longDate|medium|mediumDate|mediumTime|short|shortDate|shortTime as the format for parsing.

*** It supports template literals as a string between the single quote ' character, i.e. 'The Date is' MM/DD/YYYY. If one wants the literal single quote character, one must use ''''.

close