FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.parseDate() function

Date fcf.parseDate(string a_string, string a_format = "Y*m*d*H*i*s*v", boolean a_strict = false, Date a_default = new Date(1970, 0, 1, 0, 0, 0, 0), integer a_timezoneOffset = 0)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Converts the string representation of a date and time to a Date

Arguments

string a_string
- String representation of date and time

string a_format = "Y*m*d*H*i*s*v"
- The date and time format passed in the a_string argument

You can use the following characters in the format string

Y - Year (1000-9999)

m - Month (01-12)

d - Day (01-31)

H - Hour (00-23)

h - Hour (01-12)

a - am, pm

A - AM, PM

i - Minutes (00-59)

s - Seconds (00-59)

v - Milliseconds (000-999)

* - any character

Any other character declares its mandatory presence

\ is used to escape special characters.

boolean a_strict = false
- If false, then partially matching the date/time string with the pattern returns a Date object with partially filled fields. If true, then Invalid time is returned if the format does not match exactly.

string|Date a_default = new Date(1970, 0, 1, 0, 0, 0, 0)
- Default value of timestamp fields

boolean|integer a_timezoneOffset = 0
- Time zone offset from current value ((new Date()).getTimezoneOffset(), if value is false, UTC time is used.
Result
Date
- Date object

Example: Function application

let date = fcf.parseDate("1971-02-01T09:01:01", undefined, undefined, undefined, false); console.log(date);

Output:

1971-02-01T09:01:01.000Z