 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Websanova.com: Timezones, the Right Way
by Chris Cornutt December 14, 2012 @ 10:17:21
On the Websanova.com site there's a recent post about doing timezones the right way when working with them in PHP and storing them in your (MySQL) database.
Timezones are actually a very trivial concept but they seem to be overlooked and over complicated. [...] Rather than storing a timezone with each date it's better to just accept a standard time to store all your dates with, thus doing the conversion to that standard time before storing the value in the database. It doesn't really matter what time we store it as, but it's generally a good idea to just use UTC+00:00.
They talk a little about what the UTC timezone is for those that may not know and show how to set it as the default timezone for your PHP application (with date_default_timezone_set or updating your php.ini). They also include the MySQL configuration option to set its default timezone and and example SELECT statement for extracting the data back out.
voice your opinion now!
timezone mysql database utc datetime default
Derick Rethans' Blog: To GMT or not to GMT
by Chris Cornutt March 01, 2012 @ 11:39:45
In this new post to his site, Derick Rethans shows an instance of "GMT being tricky" when it comes to "UTC" versus "GMT" output from PHP's DateTime object.
Earlier today, on twitter, @skoop asked: "dear #lazyweb, when I use DateTimeZone('GMT'), why does format('e') output UTC?" [...] As you can see [the example with a format of "e" on a DateTimeZone('GMT')] has UTC and not GMT as you might expect.
Derick mentions that sometimes, systems require "GMT" instead of "UTC" in the output they're given. To work around this issue, he shows how to add a "type 2" timezone to the DateTime object by including it when you initialize the object (code samples included). Using alternative methods, you can add these "type 2" timezones in three ways - an offset in the initial string, using the abbreviation (like "EST" or "PST") and specifying the long version of the timezone (like "America/Montreal").
voice your opinion now!
datetime handling timezone gmt utc type2 initialize offset
Stephen Colebourne's Blog: Time-zone database down
by Chris Cornutt October 07, 2011 @ 12:48:02
In a new post to Stephen Colebourne's blog today, there's some bad news for developers of software and OSes in general - the timezone database that most software uses is down due to a copyright struggle with a company named Astrolabe, Inc.. How does this relate to PHP? It's the same database the language uses to define its timezones as a part of the DateTime functionality.
The time-zone database (sometimes referred to as the Olson database) is the computing world's principle source of time-zone data. It is embedded in every Unix and Java for starters, and will be used by many websites and probably by your iPhone. You may know it via the IDs, such as "Europe/London" or "America/New_York". But, perhaps you're thinking that time-zones don't change? Well that may be true for America and the EU right now, but certainly isn't for the rest of the world.
Astrolabe claims that the database is a part of the work on their "ACS Atlas" product and the contents of it belong to them.
The impact of this is severe for anyone that uses it - whether via Java, Unix or some other means. This really is the key tool used by everyone to tell the right time globally. We all owe a debt of gratitude to the database maintainers who have worked on this for many, many years at zero cost to the industry and for zero financial gain.
Stephen puts out a call to some of the larger technology leaders/companies to help resolve this situation and/or provide a resource where this information can once again be accessed freely.
voice your opinion now!
timezone database astrolabe copyright shutdown
Ibuildings techPortal: Tips for Working with DateTime in PHP
by Chris Cornutt May 04, 2010 @ 13:33:29
In the latest post from the Ibuildings techPortal Lorna Mitchell takes a look at one of the more powerful features included in PHP versions 5.2 and greater - the DateTime class.
In the newer PHP 5.3 versions even more excellent functionality was added. This is a short post to introduce this functionality with a focus on the methods available in PHP 5.2 showing some simple examples of how we can more easily manipulate and display dates without needing to work with timestamps.
She shows how to create a simple DateTime object, how to change up the timezone information related to it and has an example of how to output the format with a call to the format function. She also mentions how they can simplify the storage of date information in a database since they can be moved around between timezones easily (instead of having to calculate the different between where it was created and where it's being used).
voice your opinion now!
datetime tip tutorial example timezone
Zend Framework By Examples: Handling dates and times (Zend_Date)
by Chris Cornutt January 22, 2010 @ 11:09:45
The Zend Framework By Examples site has posted a recent tutorial about using the Zend_Date component of the Zend Framework to work with dates and times in your PHP applications.
In this example, we get or set dates in different timezones. We display parts of dates and times in various formats. We also get information on sunrise and sunset in several locations.
They also incorporate other components in the examples including Zend_Cache, Zend_Locate and Zend_Registry. Their examples show how to check the locale, verify the timezone and figure out a "date from now". Complete code is included - it's not the best method to handle some parts of the example, but it's a rough guide in the right direction.
voice your opinion now!
zenddate zendframework tutorial timezone
Vancouver Web Consultants Blog: Getting Time Zone from Latitude & Longitude
by Chris Cornutt May 08, 2009 @ 11:15:30
On the Vancouver Web Consultants blog there's this new tutorial about grabbing latitude and longitude information for a location and determining its current time zone from there.
I was recently tasked with building an application that relied heavily on accurate time zone conversions. I, like many people I soon found out, thought there were just a handful of timezones and the usual select list would suffice. The deeper I looked into the problem, the deeper it got: the list above only shows a few time offsets from UTC, but it doesn't tell me, beyond a shadow of a doubt, exactly what time it is where the user is situated, nor can I rely on that time for calculations in the future. The fact is, here are a LOT of timezones in the world.
He came across the DateTimeZone class PHP has to offer and was happy to see it met his needs. Unfortunately, users weren't always sure what timezone they were in, so he came up with a system combining Google's Maps API and GeoNames.org. He includes the code for both the PHP and Javascript sides (the Javascript requires Mootools, but it could be easily adapted to any other Javascript libraries).
voice your opinion now!
timezone latitude longitude googlemaps geonames datetimezone
Terry Chay's Blog: How much does a date() cost?
by Chris Cornutt May 07, 2009 @ 11:18:28
In a new post to his blog Terry Chay looks at the real cost of a (call to) date() - the PHP function that can parse either the current or an inputted timestamp out into the date format you specify.
One of the fringe benefits of open sources an existing code base is that you have an opportunity to setting error_reporting on E_ALL | E_STRICT or perhaps rather just to 2147483647. When you do that you find small problems with your code base you missed the first time you sloppily wrote it. In my case, I noticed that date() was throwing strict errors.
Due to his resulting request to test the error (after submitting a ticket to fix the server's php.ini settings), he went about trying to test and see what the real impact of working with the date function was by developing his own simple benchmarking script. It runs through five different tests some with a default timezone set and some not. His results found that doing it in the script versus on the server's config didn't make much of a difference so he corrected the issue with a quick ini_set (or a date_default_timezone_set).
voice your opinion now!
date timezone default benchmark iniset datedefaulttimezoneset
|
Community Events
Don't see your event here? Let us know!
|