Re: [PHP] function CreateDate i made doesnt work?
From: Andy B [EMAIL PROTECTED] i have the function i made: function CreateDate($day, $month, $year) { if(!empty($day) !empty($month) !empty($year)){ //convert $day, $month, and $year into a valid timestamp $time= strtotime($day, mktime(0,0,0,$month,1,$year)); $time=date(YmdHis, $time); Replace the above two lines with $time = date('YmdHis', mktime(0,0,0,$month,$day,$year); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function CreateDate i made doesnt work?
Hello Andy, Tuesday, April 6, 2004, 2:18:45 PM, you wrote: AB i have the function i made: AB function CreateDate($day, $month, $year) { AB if(!empty($day) !empty($month) !empty($year)){ AB //convert $day, $month, and $year into a valid timestamp AB $time= strtotime($day, mktime(0,0,0,$month,1,$year)); AB $time=date(YmdHis, $time); AB return $time; } AB else { AB return false; }} ? AB my output ends up being Monday January 18, 2038 no matter what i AB try to use in the forms. Your function doesn't seem to make any sense to be honest - you're passing in the $day value to strtotime (a function that ideally requires English language date formats) and then asking it to calculate a timestamp based off the offset of the month and year. So ultimately you're feeding strtotime = 10, timestamp which means it's going to try and calculate the difference between 10 and the given timestamp (which is going to be a lot!) What exactly is this function *supposed* to do? -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function CreateDate i made doesnt work?
by the way change ur if alittle.. change the to || John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] From: Andy B [EMAIL PROTECTED] i have the function i made: function CreateDate($day, $month, $year) { if(!empty($day) !empty($month) !empty($year)){ //convert $day, $month, and $year into a valid timestamp $time= strtotime($day, mktime(0,0,0,$month,1,$year)); $time=date(YmdHis, $time); Replace the above two lines with $time = date('YmdHis', mktime(0,0,0,$month,$day,$year); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function CreateDate i made doesnt work?
I've seen this type of creating a timestamp quite often now and was even so often shaking my head about it. Guess i've seen it somewhere in the PHP Documentation's user contributed notes on day. Just google for the term and you will find many hits like this: http://www.mail-archive.com/[EMAIL PROTECTED]/msg136608.html -- red PS: Guess some ppl have never heard about mktime :-) [...] Your function doesn't seem to make any sense to be honest - you're passing in the $day value to strtotime (a function that ideally requires English language date formats) and then asking it to calculate a timestamp based off the offset of the month and year. So ultimately you're feeding strtotime = 10, timestamp which means it's going to try and calculate the difference between 10 and the given timestamp (which is going to be a lot!) What exactly is this function *supposed* to do? [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] function CreateDate i made doesnt work?
From: Andy B [EMAIL PROTECTED] Replace the above two lines with $time = date('YmdHis', mktime(0,0,0,$month,$day,$year); ok the function works now because when i echo the output of $_SESSION['add']['start_date'] it shows the right 14 digit timestamp for the date i wanted to create... now the problem is getting it to echo on a page in a normal standard user readable format... i have the following line i used to attempt that with but still..no matter what i put in the form for a date it returns monday january 15 2038..or in one instance of playing with it even ended up with december 31 1969... even though i put in the date i wanted ... say first saturday 9 (september) 2004 here is the line i used: something must be wrong with it Start Date: ?echo date(l F j Y, $_SESSION['add']['start_date']);? date() expects a UNIX timestamp. MMDDHHMMSS is NOT a UNIX timestamp. So, instead of converting the UNIX timestamp to MMDDHHMMSS in your function, why not leave it a UNIX timestamp? Then you can send it through date() whenever you want it formatted. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php