COMPANY

BLOGS

  • user warning: Unknown column 'u.signature_format' in 'field list' query: SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data, c.thread, c.status FROM comments c INNER JOIN users u ON c.uid = u.uid WHERE c.nid = 19557 AND c.status = 0 ORDER BY c.cid LIMIT 0, 50 in /var/www/www.4d.com/docs/modules/comment/comment.module on line 991.
  • warning: file_get_contents(http://www.telize.com/geoip/54.224.197.86) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /var/www/www.4d.com/docs/includes/common.inc(1762) : eval()'d code on line 4.

Timestamp mon amour (4th and final)

14.09.2010
by Olivier Deschanels
hourglass

 

This blog post is the final in a four-part series written in French in September 2009.


To finish this series, here are a few items allowing us to further appreciate the usefulness of timestamps.

 

 

- One could object that calculating timestamps takes time in interpreted databases. This is debatable, but there is nevertheless the possibility of doing better. in fact, with 4D v11 SQL, an interpreted database can callcompiled components. Nothing is is stopping you from accelerating your application, if need be, by offloading timestamp-related calculations to a specialized component.

 

- If, like me, you develop applications published on the Web, you'll undoubtedly need to display dates and times in your users' time zones. You'll appreciate the ability to subtract (or add) 3600 seconds per hour of time difference. You no longer need to verify whether the date needs to change. There's no more hassle of Australian time zones that differ by half-hour blocks, or 15-minute blocks in certain Pacific islands.

 

- To round off timestamps to the minute (and eliminate seconds), you just need to round the timestamp to 60:

$timestamp_min:=$timestamp-($timestamp%60).

- If in order to optimize your code you're using arrays, you will definitely prefer to use one single array rather than two... 

 

- To display a timestamp, you need to convert it to something legible. But there's no need to pass an additional variable in your formula, because as of version 11, you can directly place an expression in the properties list of a variable instead of its name.

 

RSS 0 comment(s) to this post