PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
mcog_esteban
Forum Contributor
Posts: 127 Joined: Tue Dec 30, 2003 3:28 pm
Post
by mcog_esteban » Wed Apr 02, 2008 9:57 am
Hello.
Using this code, why i'm having diferent results with this code ?
Code: Select all
$day = 60*60*24;
$status = 'Wed Aug 11 13:03:20 WEST 2010';
$expire_date = date("d/m/Y", strtotime($status));
var_dump($expire_date);
$expiration_date = strtotime($expire_date);
$today = date("d/m/Y");
var_dump($today);
var_dump( ($expiration_date-strtotime($today))/$day );
$today = date("d/m/Y", strtotime('now'));
var_dump( ($expiration_date-strtotime($today))/$day );
$today = strtotime('2 April 2008');
$august_11_2010 = strtotime('11 August 2010');
var_dump( ($august_11_2010-$today)/$day);
Results:
Code: Select all
string(10) "11/08/2010"
string(10) "02/04/2008"
int(1008)
int(1008)
int(861)
what i'm missing here ?
Last edited by
John Cartwright on Wed Apr 02, 2008 10:05 am, edited 2 times in total.
Reason: please use [code=php][/code] tags
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Apr 02, 2008 10:09 am
Would you care to explain what the problem is? I don't like puzzles
mcog_esteban
Forum Contributor
Posts: 127 Joined: Tue Dec 30, 2003 3:28 pm
Post
by mcog_esteban » Wed Apr 02, 2008 10:23 am
Jcart wrote: Would you care to explain what the problem is? I don't like puzzles
Sorry, i've figured it out how to correct the calculs.
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Wed Apr 02, 2008 10:25 am
PHP uses US time formatting ... if you put "2/4/2010" into strtotime() it assumes you mean Feb 4th rather than 2nd April.
mcog_esteban
Forum Contributor
Posts: 127 Joined: Tue Dec 30, 2003 3:28 pm
Post
by mcog_esteban » Wed Apr 02, 2008 10:30 am
onion2k wrote: PHP uses US time formatting ... if you put "2/4/2010" into strtotime() it assumes you mean Feb 4th rather than 2nd April.
that must have been my error.