snorky Posted August 18, 2009 Share Posted August 18, 2009 The goal is simple: I want to display "August 31, 2009" I RTFMed and tried various date functions. I got inconsistent results, so I did some "sanity check" tests. The results were better, but not completely as expected. Some returned Tuesday, August 18, 2009 15:08:45 Others returned Wednesday, December 31, 2008 00:12:01 <?php // php 5.2 $rightnow=$_SERVER['REQUEST_TIME']; $fmt= "l, F d, Y H:m:s"; // V $thev = mktime(0,0,1,08,31,2009); $dayv = date($fmt,$thev); // returned [b]Wednesday, December 31, 2008 00:12:01[/b] // W $thew = time(00,00,01,08,31,2009); $dayw = date($fmt,$thew); // returned [b]Tuesday, August 18, 2009 15:08:17[/b] (current time) // X $thex = time(); $dayx = date($fmt,$thex); // returned [b]Tuesday, August 18, 2009 15:08:17[/b] -- as expected // Y $dayy = date($fmt,$rightnow); // returned [b]Wednesday, December 31, 1969 16:12:00[/b] (!!!) // Z $dayz = date($fmt); // returned [b]Tuesday, August 18, 2009 15:08:17[/b] -- as expected ?> What is the correct syntax to display August 31,2009 Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 18, 2009 Share Posted August 18, 2009 Take the time part out of your $fmt. Also obviously $rightnow isn't being set. Try printing it before using date(). Wednesday, December 31, 1969 is the epoch. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.