For example, suppose that you have a timestamp field named "DateTime_Created" with a value of "7/30/2009 9:18:29 PM." If you simply echo the value using PHP code such as...
echo $response->getField("DateTime_Created");
... then the output returned by PHP will look something like this:
07/30/2009 21:18:29
That's not terrible looking, but it's not pretty either.
Suppose that you want to format the value using the type of date/time formatting options that FileMaker provides. The solution is to use a combination of PHP's date and strtotime functions. These functions make it very easy to format timestamp values in a wide variety of ways.
For example, if you want to display the value in a format such as "day name, month day, year" you could use this:
echo date("l, F j, Y", strtotime ($response->getField("DateTime_Created")));
Using that date format, PHP will return:
Thursday, July 30, 2009
The "l, F t, Y" argument that we're passing to the date function is used to specify the format. In this case, the "l" represents the name of the day of the week (Thursday), the "F" represents the name of the month (July), the "j" represents the day of the month (31), and the "Y" represents the year (2009).
Adding the time to the value is easy. You can use this:
echo date("l, F j, Y @ g:i A", strtotime ($response->getField("DateTime_Created")));
... and the output returned by PHP will now look like this:
Thursday, July 30, 2009 @ 9:18 PM
With that format, the "g" represents the hour (9), the "i" represents the minutes (18) and the "A" represents the Ante meridiem or Post meridiem (PM).
To get a better feel for the various formatting options that are available, check out the PHP Date function documentation.
And finally, you might be wondering why the "strtotime" function is necessary. That function converts the FileMaker value into a Unix timestamp. (The "date" function needs the date value to be a Unix timestamp.)
In summary, with PHP's date and strtotime functions, we can easily format FileMaker timestamp values in a wide variety of ways.

