News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ben Ramsey:
Dates Are Hard
February 24, 2014 @ 09:03:24

In a new post to his site Ben Ramsey talks about why dates are hard and can be frustrating to work with sometimes. It revolves around an issue he recently found with calculating a time for a UUID and days of the week.

No, I'm not talking about a meeting with a lover or potential lover. While those can be stressful, the calendar math used to determine the precise date and time on which such a meeting might occur is infinitely more difficult to perform. To software programmers, this isn't news, but I recently encountered an issue when calculating the time for an RFC 4122 UUID that had me questioning the accuracy of our modern, accepted calendars, especially with regard to the days of the week on which our dates fall.

In his work on his UUID library, he came across a the bug because of some failing unit tests. It was only happening in certain versions of PHP and upon further investigation found the issue to be a wrong day of the week from a date in 1582 (the correct value being Sunday). As it turned out, the date in question was actually a Saturday and his local environment was reporting bad results. The problem was with a revision made to the Gregorian calendar, removing 10 days causing a difference between the Gregorian and Great Britain versions of 1582.

0 comments voice your opinion now!
date time calendar gregorian unittest greatbriain year

Link: http://benramsey.com/blog/2014/02/dates-are-hard/

NetTuts.com:
Dates and Time - The OOP Way
October 24, 2013 @ 11:49:23

On NetTuts.com today there's a new tutorial they've posted showing how to use PHP's DateTime functionality in a more OOP kind of way. The DateTime extension lets you work both ways - procedural and OOP, with only slightly different syntax changes between them.

The Date/Time PHP extension is a set of classes that allow you to work with almost all of the date and time related tasks. It's been available since the release of PHP 5.2 and the extension introduced several new classes.

The tutorial first shows you some of the differences between just working with something like date and DateTime. From there they get into a bit more complicated things like:

  • Modifying dates/times
  • Working with multiple dates
  • Working with timezones
  • Using DatePeriods
  • Extending the current functionality

There's also two more "real world" usage scenarios included - defaulting to using UTC times and using the DateInterval to handle subscription payment logic.

0 comments voice your opinion now!
datetime tutorial oop introduction date time

Link: http://net.tutsplus.com/tutorials/php/dates-and-time-the-oop-way/

Derick Rethans:
ISO 8601 week dates
September 24, 2013 @ 09:54:31

Derick Rethans has a new post with details about handling ISO 8601 dates in PHP via the DateTime functionality. It's a response to some bugs filed having to do with week numbering.

Week numbers are defined in this same ISO 8601 standard. Each year has 52 or 53 weeks and weeks always start on a Monday. Week number 1 of each year is the first week in a year that has the first Thursday of the year, or in other words, the week containing January 4th.

He talks about some of the date format arguments that use would use when working with the ISO 8601 formatting and how it relates to the calendar year. He points out that the "Y" format specifier is not the same as the "o" - the first being the calendar year while the second relates to the ISO 8601 year.

As conclusion, this article shows that there are two ways representing dates in PHP. In the Gregorian1 calendar with year, month and day (of month), and in the ISO 8601 calendar with year, week and day (of week). The format characters for the two different years are either Y or o and they should not be confused.
0 comments voice your opinion now!
iso8601 date datetime format specifier gregorian calendar difference

Link: http://derickrethans.nl/iso-8601-weeks.html

PHPClasses.org:
Lately in PHP, Episode 36 - PHP 5.5 Release Date Imminent
June 17, 2013 @ 09:30:38

On the PHPClasses.org site Manuel Lemos has posted the latest episode of the "Lately in PHP" podcast series. This episode, number 36, talks about the upcoming release of PHP 5.5 and looks forward to 5.6.

The PHP 5.5.0 final release is about to happen. After about 16 months of development PHP 5.5 is bringing even more maturity to the PHP language, which by Google numbers is present in 75% of the Web sites. [...] hey also discussed some new features proposed for PHP 5.6 like incremental decoding of large JSON data streams and overloading arithmetic operators for arbitrary precision math. They also debated the meaning of Google finally adding support to PHP in their cloud hosting platform Google AppEngine. Also in this episode it was discussed an article about good practices to quickly detect and fix PHP code bugs that only show up in production environments.

You can listen to this latest episode either through the in-page player, by downloading it directly or you can watch the video of the live recording on YouTube.

0 comments voice your opinion now!
release date latelyinphp podcast series ep36 appengine

Link: http://www.phpclasses.org/blog/post/209-PHP-55-Release-Date-Imminent--Lately-in-PHP-podcast-episode-36.html

PHPClasses.org:
Lately in PHP, Episode 28 - PHP 5.5 Release Date and Plans
October 15, 2012 @ 08:40:06

On the PHPClasses.org blog they've posted the latest "Lately In PHP" Podcast - Episode #28, "PHP 5.5 Release Date and Plans":

PHP 5.5 release is already being planned. The release manager was picked, the new features are decided and the release date is estimated. This one of the main topics discussed by Manuel Lemos and Ernani Joppert in episode 28 of the Lately in PHP podcast. They also discussed the interpretation from VentureBeat that Zend is working on mobile version of PHP, using abstract symbol tables to optimize PHP further, and creating classes that provide APIs that are simpler for the users.

You can listen to this latest episode either using the in-page player, by downloading the mp3 or by subscribing to their feed.

0 comments voice your opinion now!
release date latelyinphp podcast phpclasses language


Gonzalo Ayuso:
Handling dates with PHP
October 02, 2012 @ 08:41:09

In this new post to his site Gonzalo Ayuso introduces you to one of the more powerful parts of the PHP language - the DateTime object.

I've seen a lot of newbies (and not newbies) having problems handling dates in PHP (and even with SQL and another languages). When I see someone having problems with dates, I always ask the same question. I type in a text editor "27/11/2012″ and I ask him: What is it? If your answer is "This is a date" you should continue reading the post.

He talks about how the DateTime functionality replaces (much more effectively) some of the older date handling methods in PHP. He includes a few examples comparing it to date and showing how it can be used to compare dates. He includes a "Dummy" class he mocked up to show how you could work with DateTime to get/set formatted dates, set the format to use and get the current format. As always, he also provides tests for the code as well.

This is just the tip of the iceberg as to what DateTime can do, so I'd suggest checking out the manual page for it to see the full list of features.

0 comments voice your opinion now!
datetime date time handling introduction formatting


PHPMaster.com:
Working with Dates and Times in PHP and MySQL
March 01, 2012 @ 08:51:47

On PHPMaster.com today there's a new tutorial by Sean Hudgston about working with dates and times via the PHP date functions and how they cooperate with dates/times from a MySQL database.

When working in any programming language, dealing with dates and time is often a trivial and simple task. That is, until time zones have to be supported. Fortunately, PHP has one of the most potent set of date/time tools that help you deal with all sorts of time-related issues: Unix timestamps, formatting dates for human consumption, displaying times with time zones, the difference between now and the second Tuesday of next month, etc. In this article I'll introduce you to the basics of PHP's time functions (time(), mktime(), and date()) and their object-oriented counterparts, and then take a look at MySQL dates and show you how to make them play nicely with PHP.

His examples include how to get the current Unix time, formatting dates/times, making timestamps and working with the more powerful DateTime objects. On the MySQL front, he shows the result of a normal date select, one using the "unix_timestamp" function and how to shift the result based on the user's timezone.

0 comments voice your opinion now!
date time mysql datetime tutorial format unix timestamp


Brian Moon's Blog:
Errors when adding/subtracing dates using seconds
January 17, 2012 @ 11:19:22

Brian Moon has a reminder about date handling in PHP - days are not always 86400 seconds long, sometimes there's "leap seconds" included too. Thankfully, there's easy ways around it:

The problem with this is that it assume that there are only 86400 seconds in every day. There are in fact not. On days when the clocks change for daylight savings time, there are either 1 hour more than that or 1 hour less than that. In addition, there are also leap seconds put into our time system to keep us in line with the sun. There is one this year, 2012, on June 30th in fact. Since they don't happen with the regularity that daylight savings time does, it may be easy to forget those. Luckily, for this problem, the solution is the same.

His first solution involves letting strtotime do the work for him, internally calculating the leap seconds or any other issue that might come up. As an alternate solution, he also mentions "doing your math at noon" - this gives you enough leeway to make the offset leap seconds could cause a much smaller risk.

0 comments voice your opinion now!
error add subtract date seconds strtotime noon


PHPClasses.org:
Lately in PHP podcast episode 17 - PHP 5.4 & PHP-GTK in the Browser
October 31, 2011 @ 12:50:53

On PHPClasses.org today they've released their latest episode of their "Lately In PHP" podcast - episode #17. In this new episode Manuel and Ernani talk about PHP-GTK in a web browser and the proposed PHP 5.4 release date.

PHP 5.4 beta 2 was just released, so the final version of 5.4.0 is coming soon. Many PHP Developers want to know when it will be the final PHP 5.4 release date. Manuel Lemos and Ernani Joppert talk about this and other interesting PHP related topics in episode 17 of the Lately in PHP podcast.

You can listen to this latest episode either through the in-page player, by downloading the full mp3 or by subscribing to their feed to get this and past episodes (including ones about MODX and PHPFog).

0 comments voice your opinion now!
phpgtk browser podcast latelyinphp release date


WebInOne.net:
Date validation for CodeIgniter 2
October 07, 2011 @ 11:57:21

On the WebInOne blog there's a post about doing some date validation in CodeIgniter 2 forms using the "set_validation" method.

I wrote a tutorial here about the CI date. At that post I used the HTML <select> for the input of date. Sometime our client can want to use text box for the date input. We need the validation for this date. I have found this code from here. It is for CI 1.7.* and PHP 5.2.*. So I change some code for the CI 2.0.* and PHP 5.3.*.

There's some code snippets included in the post showing how to use it in the form (HTML), setting the validation on the form object (for US and UK validation) and the actual code of the updated custom Validation class.

0 comments voice your opinion now!
date validation tutorial framework snippet form



Community Events





Don't see your event here?
Let us know!


symfony2 community list introduction unittest code refactor laravel install opinion interview language series framework release developer configure testing podcast threedevsandamaybe

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework