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

fcf.formatDate() function

string fcf.formatDate(Date a_date, string a_format = "Y-m-d H:i:s.v", integer a_timezoneOffset = 0)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Converts a Date object to a string representation

Arguments

Date a_date
- The Date object to be converted to a string representation

string a_format = "Y-m-d*H:i:s.v"
- A string indicating the format of the source string

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 other character declares its mandatory presence

\ is used to escape special characters.

integer a_timezoneOffset = 0
- Time zone offset from current value ((new Date()).getTimezoneOffset(), if value is false, UTC time is used.
Result
string
- A string containing the date and time in the given format

Example: Function application

let date = fcf.formatDate("1971-02-01T09:01:01"); console.log(date);

Output:

1971-02-01 09:01:01.000