View Single Post
Old 12-13-2007, 07:07 PM   #1 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default Most efficient way of playing with dates?

So I've got this unix timestamp from the past which I needed to convert into a date:
PHP Code:
$firstDate date('Y-m-d H:i'1195958278); 
Next I added 90 days:
PHP Code:
$expiry date('Y-m-d H:i'strtotime('+90 day'$firstDate)); 
This is because each pass is valid for 90 days after the first date. I then proceed by figuring out how many days are left for the pass to expire:
PHP Code:
$daysLeft 365 - (date('z'strtotime(date('Y-m-d H:i'))) - date('z'strtotime($expiryDate))); 
I've tested it with a bit of data and it seems to work.

Does anyone see something totally wrong? Or maybe an easier alternative?

Thank you.
bdm is offline  
Reply With Quote