CMellor Posted January 18, 2007 Share Posted January 18, 2007 Odd as this may sound, I have only just discovered the [b]strtotime()[/b] function. I like the looks of what it is capable of and have tried to use it to my advantage. I tried to make a little script that would convert a UNIX time stamp into a message saying whether or not the stamp was a time for today, or yesterday, or if neither, then just display the date it is.I'm not a PHP pro, but am always learning. I have looked all over for tutorials on how to do this, but the only useful one's I found are for blogging software. I was hoping someone here could guide me in the right direction of where to begin coding this script, or maybe provide me with a sample that I can toy around with myself. Any help at all would be appreciated.Thanks for reading,Chris. Quote Link to comment Share on other sites More sharing options...
obsidian Posted January 18, 2007 Share Posted January 18, 2007 Well, once you've got a UNIX timestamp, you can use the date() function to parse out the year, month and day of the timestamp. Just check to see whether this date is equivalent to yesterday or today and execute accordingly:[code]<?phpif (date('Y-m-d', $timestamp) == date('Y-m-d')) { // The timestamp is from today!} elseif (date('Y-m-d', $timestampe) == date('Y-m-d', strtotime("Yesterday"))) { // The timestamp is from yesterday!} else { // The timestamp is from neither today nor yesterday!}?>[/code] Quote Link to comment Share on other sites More sharing options...
CMellor Posted January 18, 2007 Author Share Posted January 18, 2007 Awesome!!Thanks so much, just what I needed :) 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.