monkeytooth Posted February 2, 2008 Share Posted February 2, 2008 Alright.. First of whats the best thing to use to make a unix style timestamp? Next off.. I can use any of them to make a date format that readable just by looking at that I know that much and can do that much.. But I am running into a wall with trying to get it to calculate the difference in seconds, minutes, hours, days, weeks, months, years.. What I want to do, is take the timestamp I have or a new one pending on the first question I had.. Then break said time stamp down into seconds, minutes, hours, days, weeks, months, years (each one being a different $var). The concept is 2 timestamps. $timestamp1 made on the page's load.. and $timestamp2 pulled from a database that was generated sometime ago using time() but again willing to change it according to the first question. and get it to calculate the difference in seconds, minutes, hours, days, weeks, months, years.. from there the rest is semantics as to how it will layout on the page using mostly if-then style functions to determine if less then any of the $vars it won't show that element. So if less then a month it will only show seconds minutes hours days or just days in some cases or yea like I said that part is irrelivant.. I just cant figure out how to get the total difference between 1 and 2 Quote Link to comment https://forums.phpfreaks.com/topic/89088-time-mktime-etc-need-opinions-and-help/ Share on other sites More sharing options...
The Little Guy Posted February 2, 2008 Share Posted February 2, 2008 Like so: <?php $timeStamp = 112739474; //some random numbers invalid $hours = date("h",$timeStamp); $min = date("i",$timeStamp); //etc... ?> http://php.net/date Quote Link to comment https://forums.phpfreaks.com/topic/89088-time-mktime-etc-need-opinions-and-help/#findComment-456286 Share on other sites More sharing options...
monkeytooth Posted February 2, 2008 Author Share Posted February 2, 2008 Oh i wish what i wanted to do was so simple.. Like i said, I can convert it to the time the timestamp was made.. but what I'm doing is trying to find how many seconds, hours, mins, days, weeks...... there were since the orginal timestamp was made.. thank you none the less for the reply.. I know its possible, but im stumped, the best I can come up with is the ability to add and or subtract days weeks months etc to the existing timestamp to make future and past dates... but lets say timestamp1 is 987654321 (created on the pages load) and timestamp2 retrieved from a database is 123456789.. What I am doing is trying to figure out how to take the diffrence 864197532 in this example and find out how many seconds mins hours days etc there are in between 987654321 and 123456789 using the difference, if this is even possible.. Maybe theres an easier way to do this whole thing.. again I am over all open to suggestion be it in favor of what I'm saying here or something completely different that actually works.. Quote Link to comment https://forums.phpfreaks.com/topic/89088-time-mktime-etc-need-opinions-and-help/#findComment-456289 Share on other sites More sharing options...
monkeytooth Posted February 2, 2008 Author Share Posted February 2, 2008 I guess the concept would follow similar to "Last Date Modified".. or even better.. Google, Gmail to be more exact.. next to your messages they always have a column that says received: and specifies how long ago, seconds, mins, hours, days.. Quote Link to comment https://forums.phpfreaks.com/topic/89088-time-mktime-etc-need-opinions-and-help/#findComment-456302 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.