cNickerson Posted July 21, 2014 Share Posted July 21, 2014 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 More sharing options...
Larry Posted July 22, 2014 Share Posted July 22, 2014 The DateTime object was added to PHP after this edition of the book was written, I believe. Link to comment Share on other sites More sharing options...
cNickerson Posted July 22, 2014 Author Share Posted July 22, 2014 The DateTime object was added to PHP after this edition of the book was written, I believe. Is it covered in the latest version? Also is the latest version in OOP? seems like most coding is now in PHP. Thanks Larry. Link to comment Share on other sites More sharing options...
Larry Posted July 23, 2014 Share Posted July 23, 2014 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 More sharing options...
cNickerson Posted July 23, 2014 Author Share Posted July 23, 2014 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 More sharing options...
Larry Posted July 24, 2014 Share Posted July 24, 2014 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)! 1 Link to comment Share on other sites More sharing options...
Recommended Posts