Brian Dunning's FileMaker Custom Functions

FormatTimestamp ( timestampValue , format )

Returns the Timestamp date and/or time formatted as specified in format.

  Be the first to rate this function Log in to vote

Lewis Lorenz   Lewis Lorenz - Show more from this author
Lorenz Companies
http://www.LorenzCom.com

Share on Facebook Share on Twitter

  Sample input:
FormatTimestamp ( "9/21/2005 11:06:53" , "Y-m-d His \zulu\")
  Sample output:
2005-09-21 110653 zulu

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

FormatTimestamp ( timeStampValue , format )

by Lewis C. Lorenz

10/10/19 Updated

NOTICE: This is a recursive function. If you change the function name then also change it in the function code.

Returns the Timestamp date and/or time formatted as specified in format.
Optionally use the backslash as an escape code to include text not intended to be formatted.
Escaped \ is written \\, all other escaped text must be enclosed within an opening \ and a closing \.
Formatting performed using PHP date() function format codes but with Filemaker conventions.

Passing '?' as the whole value of format returns this help text and the following code explanations.

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

Examples:
FormatTimestamp ( "9/21/2005 11:06:53" , "Y-m-d His \zulu\") = 2005-09-21 110653 zulu
FormatTimestamp ( "10-3-2011" , "\today is the \jS\ day\") = today is the 3rd day

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: