prudens Posted June 4, 2008 Share Posted June 4, 2008 Hi, I have a column in mySQL that contains time() in Linux time... Like 299238923; I want to create a web page that reads that column and determine whether the time is TODAY, YESTERDAY, MAY-31, MAY-28, etc,... how do i do it? Quote Link to comment https://forums.phpfreaks.com/topic/108772-determine-today/ Share on other sites More sharing options...
prudens Posted June 5, 2008 Author Share Posted June 5, 2008 i used gmdate("Y-m-d",time()); why it says 2008-06-05 ????? instead of 06-04?? Quote Link to comment https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-557994 Share on other sites More sharing options...
Zane Posted June 5, 2008 Share Posted June 5, 2008 Linux time is just a count in seconds from Jan 1 1970 one day is 86400 seconds... so from there you can just find the difference between the current UNIX timestamp and the timestamp you have in your db if it's less than 86400...it was today if it's less than 172800 but greater than 86400 then it's yesterday Quote Link to comment https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-557997 Share on other sites More sharing options...
mushroom Posted June 5, 2008 Share Posted June 5, 2008 i used gmdate("Y-m-d",time()); why it says 2008-06-05 ????? instead of 06-04?? gmdate() returns Greenwich Mean Time. if you want local time use date() Quote Link to comment https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-558000 Share on other sites More sharing options...
prudens Posted June 5, 2008 Author Share Posted June 5, 2008 Linux time is just a count in seconds from Jan 1 1970 one day is 86400 seconds... so from there you can just find the difference between the current UNIX timestamp and the timestamp you have in your db if it's less than 86400...it was today if it's less than 172800 but greater than 86400 then it's yesterday elseif ( (time() - int($row['time'])) < 172800 && (time() - int($row['time'])) > 86400 ) is it <= or just < ?? Quote Link to comment https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-558041 Share on other sites More sharing options...
melvinchi Posted June 5, 2008 Share Posted June 5, 2008 I think you can just do the following... Pull the info from your database.. $Transaction_Info = array('Check_Number'=>mysql_result($result, $i, "Check_Num"), 'Pay_To'=>mysql_result($result, $i, 'Pay_To'), 'Date'=>mysql_result($result, $i, "Date"), 'Transaction_Type'=>mysql_result($result, $i, "Transaction_Type"), 'Amount'=>mysql_result($result, $i, "Amount"), 'Comments'=>mysql_result($result, $i, "Comments")); Now just display it echo date("m/d/Y", time($Transaction_Info['Date'])) I pulled this from a project i was working on a while back all you really need to worry about is 'Date'=>mysql_result($result, $i, "Date"), this is just putting the timestamp form the database into an array then you can just echo it. Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-558084 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.