During the PHP London conference (slides are here as usual), a number of British people were "complaining" that PHP's strtotime() and date_create() /new DateTime() functions do not understand the British date format "dd/mm/yyyy". Historically, the "English" text to date parsers in PHP only accept the illogical American format of "mm/dd/yyyy". Having seen this problem before, I recently added a new function/method to PHP's Date/Time support to address exactly this issue.
Timezones in web applications are often dealt with the same way as character sets. Either incorrectly or ignored. The case of unicode is improving slowly as developers discover the need for international language support.
The problem with not handling timezones correctly is not apparent in the usual case of the webserver and the database server being in the same timezone. A lot of PHP code passes the task of timestamps on to MySQL, e.g. by calling NOW() on inserting or updating records. It is nessesary to know in what timezone the timestamps are stored to process them correctly.
Often a specific timezone is assumed for displaying date and time. This could very well be incorrect for a large number of visitors. If the database server is in yet another timezone, things begin to get out of sync.
MySQL's handling of timezones is - obviously - separate from that of PHP. Along with the fact that the MySQL timezone can only be changed by users with SUPER privileges, this means that MySQL cannot be relied on for creation of timestamps in correct timezone. In other words, the usual call to NOW() is not an option.
PHP comes with an extensive catalog of date and time functions, all designed to let you easily retrieve temporal information, massage it into a format you require, and either use it in a calculation or display it to the user. However, if you'd like to do something more complicated, things get much, much hairier.
Tutorial kommentieren Defekten Link melden
Rehan schreibt:
Извините, но мне кажется вы меня не поняли. Объясните пожалуйста. Вот на площадке на всех страницах разрешено размещение только 1 ссылки. Как организовать показ ссылки по выбору оптимизатора в виде блока или в виде ссылок?Ведь вебмастеру в данном случае остается выбирать либо блок, либо обычная ссылка.Или можно в одно и тоже место поставить rtuern_links() и rtuern_block_links() и оптимизатор сможет выбрать тип размещения на странице?Прошу обратить внимание, что на страницах только 1 место для размещения.
Jamesjay schreibt:
חומד, אם כבר משנים את העבודה שלי ונותנים לי עליה קרדיט, לפחות מוטב שלא לעוות אותה באמצעות שינוי קלוקל של פרמטרי אורך-רוחב, וגם לדאוג שלא יהיה שם tiling מכוער שכזה :Dוברכות לרגל זניחת הקאפצ'ה המזורגגת.להגיב
As a former ASP.Net coder, I've missed the convenience of Microsoft's built-in Calendar Control since I switched to doing Web site development in PHP. On a recent project I needed the ability to display a calendar with dates serving as hyperlinks to selected database items. I decided to use the opportunity to write some portable PHP code that I could use in other projects.
This tutorial will teach you how to convert temporal values between time zones with the PEAR Date class. It assumes that you have a working Apache and PHP installation and that the PEAR Date class has been correctly installed.
This article will show you how to use dates and times in PHP & MySQL, by taking a look at the problems that arise when handling dates and times, and how to solve them
Suppose you want to know the age of a person given her birth date. Lets say her birth date is "09-23-1969". Although in this case you might say that we dont need a program to compute the age, but assuming there are 1000s of records in your database...
In this article Mauricio shows us some examples of how to use the date/time features with MySQL and PHP including the UNIX timestamp and the PHP date_diff() function.
The purpose of this tutorial is to talk about two seperate concepts; profiling and object oriented programming (OOP). In this tutorial we'll create a simple class to allow you to create one or more timers. You can then use these timers to show you how long a script or function takes to run, which can help you determine what portions of your script are eating up the most processing time. This is sometimes referred to as profiling. You can also use timer objects to provide generic timer display in your scripts.
PHP provides some nice date manipulation functions that work very well in combination with each other. However, they only handle dealing with the server's timezone. Adding the feature for shifting dates to a user-defined timezone can be a very unpleasant experience, as we know first hand. In this article, we discuss the problems we encountered, and present our solution.








