FormatDateTime
FormatDateTime ( dateValue , timeValue , format )
FormatDateTime formats FileMaker Pro date and time data using PHP Date formatting syntax. Returns a string of the dateValue and/or timeValue as specified in format. If dateValue or timeValue are empty current date or current time are used. Optionally, use the backslash as an escape code to include text not intended to be formatted. This custom function formats the output using PHP Date function format codes but with FileMaker conventions.
Parameters
- dateValue – If empty the current date is used.
- timeValue – If empty the current time is used.
- format – Specifies the content of the returned string. Optionally use the backslash as an escape code to include text not intended to be formatted.
Examples
- FormatDateTime ( 10-31-2011, “”, “D., F j, Y”) = Mon., October 31, 2011
- FormatDateTime ( 10-31-2011, 8:46:21, “Y-m-d His \zulu\”) = 2011-10-31 084621 zulu
- FormatDateTime ( 10-3-2011, “”, “\today is the \jS\ day\”) = today is the 3rd day
HELP
Passing ‘?’ as the only text in format returns this help text with the following code explanations.
Escaped \ is written \\, all other escaped text must be enclosed within an opening \ and a closing \.
Formatting performed using PHP Date function format syntax but with FileMaker Pro conventions.
Day ——-
- d – 01-31
- D – Mon-Sun
- j – 1-31
- l (lowercase ‘L’) – Sunday-Saturday
- N – 1 (Monday) … 7 (Sunday). (PHP convention: ISO-8601 representation of day of week.)
- S – st, nd, rd or th (English ordinal suffix.)
- w – 1 (Sunday) … 7 (Saturday). (PHP convention : 0 (for Sunday) through 6 (for Saturday).)
- z – 1-366. (PHP convention: 0-365.)
Week —–
- W – 1-54, week of year Jan. 1. (PHP convention: ISO-8601 week number of year, weeks starting on Monday.)
Month —-
- F – January-December
- m – 01-12
- M – Jan-Dec
- n – 1-12
- t – 28-31
Year —–
- L – Leap year (1/0)
- o – year number. ISO-8601 year number.
- Y – 4 digit year
- y – 2 digit year
Time —-
- a – am/pm
- A – AM/PM
- g – Hour 1-12
- G – Hour 0-23
- h – Hour 01-12
- H – Hour 00-23
- i – Min 00-59
- s – Sec 00-59
- u – Microseconds
NOTICE: This function is a recursive function. If you change the name of it, then change the name references inside the code.
FormatDateTime code: Copy the selected code below (click on Select All to highlight all the code) to the clipboard and paste it into a newly created Custom Function. Download the code in a text file from here.
Comments
FormatDateTime — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>