dombrorj Posted January 6, 2010 Share Posted January 6, 2010 I'm trying to get whatever the date was 3 days ago to display in an html document. And I need is the month on one line and the day on another. If today's date is January 2nd, for example, the date has to display December 31. So my html looks like this... <head> </head> <body> <p>the date 3 days ago was: <br> December <br> 31 </body> Can someone help me with the php code to use here? What I've found so far won't actually display anything in my browser, so I may be doing it entirely wrong. I use other php scripts, and am certain my server has php 5 enabled. But maybe there's something else that has to be enabled? Thanks for the help. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 6, 2010 Share Posted January 6, 2010 you can use strtotime with date e.g <?php echo date('F d', strtotime("-3 days")); ?> Quote Link to comment Share on other sites More sharing options...
mrbuter Posted January 6, 2010 Share Posted January 6, 2010 edit: got beat Quote Link to comment Share on other sites More sharing options...
dombrorj Posted January 6, 2010 Author Share Posted January 6, 2010 you can use strtotime with date e.g <?php echo date('F d', strtotime("-3 days")); ?> Excellent, thanks! I couldn't get it to work at first when the doc was saved as an html file. Once I saved as a php file and uploaded to server, it worked. Is that necessary? (clearly don't know what I'm doing) One other question... the format of the month is spelled out entirely, i.e. "December" Is there an easy way to make the months abbreviated, i.e. "Dec" Thanks! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted January 6, 2010 Share Posted January 6, 2010 You would have to save your files with .php that is how the server identifies and parses out your php files unless you configure the server differently, for different date formatting you can see the following link http://php.net/manual/en/function.date.php there are examples which show you how you can format your date Quote Link to comment Share on other sites More sharing options...
mrbuter Posted January 6, 2010 Share Posted January 6, 2010 Change the "F" to an "M". http://us.php.net/manual/en/function.date.php Quote Link to comment Share on other sites More sharing options...
dombrorj Posted January 6, 2010 Author Share Posted January 6, 2010 That did it! Thanks to both of you for your help. Much appreciated 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.