Jump to content
Larry Ullman's Book Forums

Recommended Posts

Been a while since I read the book but I was going through it again and cannot find any info on PHP DateTime.

I was having a problem with timestamps not displaying the correct time using the example below. The problem is Daylight Savings Time is currently in effect and is causing the time to be off by an hour. I had asked others and they said to use DateTime. I tried reading the php.net manual but it is very confusing and doesn't have any good examples of how to get a current time stamp and then adjust to a users timezone.

Am I missing a part of the book that explains DateTime?
 

<?php

date_default_timezone_set("UTC");

$timezone = -5.0;
$timestamp = time();

$local_time = $timezone * 3600 + $timestamp;

echo date( "m/d/Y - h:i A", $local_time );

?>
Link to comment
Share on other sites

I do cover it in the 4th edition. I don't do full OOP coverage in it, because that takes like 300 pages, but I do introduce using OOP in PHP, with DateTime and a couple other examples. In my PHP Advanced book, I cover OOP in detail, with lots on writing and designing your own classes.

Link to comment
Share on other sites

Thanks Larry. I already have this book "PHP 6 and MySQL 5" and "PHP 5 Advanced". Will order "PHP and MySQL for Dynamic Websites(4th edition)" and "PHP Advanced and Object-Oriented Programming(3rd edition)". You don't plan to release a new edition on either of these soon do you? Seems like right after I purchased the 3rd edition you released 4th one a month later. Bad timing. I noticed last edition was 2011, not sure if you are releasing a newer edition any time soon.

Link to comment
Share on other sites

Wasn't trying to sell you more books, but thanks! No plans to do new editions of either of these yet, but consider this a credit for a free book in the future (I'll give you one of my free copies)!

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...