Jump to content

Determine today?


prudens

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-557997
Share on other sites

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 < ??

Link to comment
https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-558041
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/108772-determine-today/#findComment-558084
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.