RE: [PHP] mktime error
I got 1081033200 Two thoughts: 1 - is $time a global variable predefined as the current time? Don't think it is?!?!?! 2 - Could it be to do with local time settings i.e. comparing american dates with UK dates (1/Aug/04 and 8/1/04)? Nunners -Original Message- From: Andy B [mailto:[EMAIL PROTECTED] Sent: 05 April 2004 11:29 To: [EMAIL PROTECTED] Subject: [PHP] mktime error On my personal machine the return value is: 1081026000 interesting... i got 1081054800 from mine with the code: ? $time=mktime(0,0,0,4,4,2004); echo $time; ? even on cli it gives the same thing -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mktime error
Your Server will most likely run in a different timezone. If both of you would use gmktime() the result will be the same. As for the negative result: Had the same problem some time ago - seams to me as if PHP doesn't like those 0,0,0 ( try 0,0,1 instead ) - You can adjust the result by reducing the result by 1 $var = mktime ( 0,0,0,4,4,2004 ) - 1 ; -- red Am Montag, 5. April 2004 12:29 schrieb Andy B: On my personal machine the return value is: 1081026000 interesting... i got 1081054800 from mine with the code: ? $time=mktime(0,0,0,4,4,2004); echo $time; ? even on cli it gives the same thing -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mktime error
Woops little mistake there, first of all it's 'gmmktime()' secondly the source should look something like: $var = mktime ( 0,0,1,4,4,2004 ) - 1; You can find a nice article on this topic here: http://www.phpbuilder.com/columns/ehresman20030911.php3?page=1 -- red [...] Your Server will most likely run in a different timezone. If both of you would use gmktime() the result will be the same. As for the negative result: Had the same problem some time ago - seams to me as if PHP doesn't like those 0,0,0 ( try 0,0,1 instead ) - You can adjust the result by reducing the result by 1 $var = mktime ( 0,0,0,4,4,2004 ) - 1 ; -- red [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mktime error
I got 1081047600 for $time=mktime(0,0,0,4,4,2004); echo $time; (RH9, PHP 4.3.4) On Mon, 5 Apr 2004 11:34:11 +0100, Nunners wrote: I got 1081033200 Two thoughts: 1 - is $time a global variable predefined as the current time? Don't think it is?!?!?! 2 - Could it be to do with local time settings i.e. comparing american dates with UK dates (1/Aug/04 and 8/1/04)? Nunners -Original Message- From: Andy B [mailto:[EMAIL PROTECTED] Sent: 05 April 2004 11:29 To: [EMAIL PROTECTED] Subject: [PHP] mktime error On my personal machine the return value is: 1081026000 interesting... i got 1081054800 from mine with the code: ? $time=mktime(0,0,0,4,4,2004); echo $time; ? even on cli it gives the same thing -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mktime error
Guys, second thought. mktime builds a unix time stamp (since the unix epoch, Jan 1, 1970 [I guess]), the difference are maybe due to time zones, because its the number of seconds since Jan,1 1970. On Mon, 5 Apr 2004 06:29:12 -0400, Andy B wrote: On my personal machine the return value is: 1081026000 interesting... i got 1081054800 from mine with the code: ? $time=mktime(0,0,0,4,4,2004); echo $time; ? even on cli it gives the same thing -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mktime error
You could do this like this ( as it is faster ): function CreateDate($day, $month, $year) { return $year.$month.$day.'00'; } CreateDate(04,04,2004) - 2004040400 But make sure you add the leading zero to $month and $day ( can be easily done (number_format for example) ) -- red Am Montag, 5. April 2004 13:20 schrieb Andy B: if you need to turn the result of mktime() into a valid mysql timestamp format then put these 2 lines in your code when needed: ? //create valid mysql timestamp(14 digit) //change to fit your liking //sorry turned into a function... function CreateDate($day, $month, $year); //make sure no arguments were left out if!empty($day) !empty($month) !empty($year)){ $time=mktime(0,0,0,'$month','$year'); //convert to a formated stamp $time=date(YmdHis, $time); return $time;} else{return false;} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php