Tech Tip: Using the String command for GMT timestamps
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: December 6, 2010
4D v12.1 introduces new functionality to the String command. Not only does this command now accept a third parameter (the addTime parameter), but it can also be used to return a timezone offset. This is useful for accurate calculations of the GMT date as needed when setting the expiration date for cookies in HTTP headers.
If you previously used the 4D Pack command (AP Timestamp to GMT) to do this, it can now be accomplished with the following lines of code:
C_TEXT($myRFCstring) $myRFCstring:=String(Current date;Date RFC 1123;Current time) // returns, for example Fri, 10 Sep 2010 13:07:20 GMT |
The Date RFC 1123 format formats a date/time combination according to the standard defined by RFC 822 and 1123. You need this format, for example, to set the expiration date for cookies in an HTTP header.