Brian Dunning's FileMaker Custom Functions

FormatTimestamp ( format ; tstamp )

Formats a time/date any way you like using a format string

  Average rating: 4.4 (30 votes) Log in to vote

Tim Mansour   Tim Mansour - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
FormatTimestamp ( "[Dayname] [D]-[MON]-[YY] [h].[mm][am]" , "" )
  Sample output:
Thursday 25-MAR-10 2.30pm

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

Formats a timestamp according to a format string, replacing date/time component placeholders with respective data. See the Substitute command in the function to determine (or change) the placeholders to use. Includes placeholders to allow upper/lower case for text components (eg, day names).
Use a null input timestamp ("") to format the current date/time.

 

Comments

simon Plint   simon Plint, Australia
Mar 24, 2010
hr12 = Mod ( h - 1; 12 ) + 1
should be
hr12 = Mod ( hr - 1; 12 ) + 1

["[am]"; If ( h < 12; "am"; "pm" )];
should be
["[am]"; If ( hr < 12; "am"; "pm" )];
 
Tim Mansour   Tim Mansour
Mar 24, 2010
I've updated the function to my latest version.
 
Kevin Smith   Kevin Smith, London
Jun 3, 2015
Watch out for when keying in the formatting parameters. The case of the parameter often controls the case of the output e.g. "[month]" vs "[MONTH]".

Here's an exception: The parameter "[mm]" generates minutes while the parameter "[MM]" generates months.
 
Tony White   Tony White, Tony White Designs, Inc.
Oct 1, 2022
Thanks! Posted some thoughts here...
https://the.fmsoup.org/t/whats-a-custom-function-youve-created-that-you-think-should-be-built-in-to-filemaker/3091/32
 

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: