[PHP] mkdate error?
The following bit of code completely baffles me as to why it doesn't work. I am doing a very simple validation where I check to see if the end date field of an inputted record is an older date than the start date. I checked this by putting in the same date for both end and start dates. Yet mkdate gives me a different value for each even though since they are both the same date, I should get the same value returned. Right? //notice the start and end date is the same. Therefore, you should get the same value for each, right? START LITTLE CODE SNIPPET $parsed_start_date=split(/, 08/02/2002); $parsed_end_date=split(/, 08/02/2002); $start_dts = mktime(, , , $parsed_start_date[0], $parsed_start_date[1], $parsed_start_date[2]); $end_dts = mktime(, , , $parsed_end_date[0], $parsed_end_date[1], $parsed_date[2]); if ($start_dts $end_dts) { echo This function thinks the end date is older than the start date.; } else { echo Whoah, it actually worked.; } END LITTLE CODE SNIPPET What am I not seeing? Thanks in advance, J. Chyun -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mkdate error?
Your working with strings right? Would your if command be: if ($start_dts gt $end_dts) { echo This function thinks the end date is older than the start date.; } else { echo Whoah, it actually worked.; } In string you should use the gt comparitive instead of the . See if this works for you, Josh Thomas RPS Internet Services -Original Message- From: jc [mailto:[EMAIL PROTECTED]] Sent: Sunday, August 11, 2002 4:01 PM To: [EMAIL PROTECTED] Subject: [PHP] mkdate error? The following bit of code completely baffles me as to why it doesn't work. I am doing a very simple validation where I check to see if the end date field of an inputted record is an older date than the start date. I checked this by putting in the same date for both end and start dates. Yet mkdate gives me a different value for each even though since they are both the same date, I should get the same value returned. Right? //notice the start and end date is the same. Therefore, you should get the same value for each, right? START LITTLE CODE SNIPPET $parsed_start_date=split(/, 08/02/2002); $parsed_end_date=split(/, 08/02/2002); $start_dts = mktime(, , , $parsed_start_date[0], $parsed_start_date[1], $parsed_start_date[2]); $end_dts = mktime(, , , $parsed_end_date[0], $parsed_end_date[1], $parsed_date[2]); if ($start_dts $end_dts) { echo This function thinks the end date is older than the start date.; } else { echo Whoah, it actually worked.; } END LITTLE CODE SNIPPET What am I not seeing? Thanks in advance, J. Chyun -- 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] mkdate error?
At 05:08 PM 8/11/2002 -0600, RPS Internet wrote: Your working with strings right? Would your if command be: if ($start_dts gt $end_dts) { echo This function thinks the end date is older than the start date.; } else { echo Whoah, it actually worked.; } In string you should use the gt comparitive instead of the . See if this works for you, Josh Thomas RPS Internet Services -Original Message- From: jc [mailto:[EMAIL PROTECTED]] Sent: Sunday, August 11, 2002 4:01 PM To: [EMAIL PROTECTED] Subject: [PHP] mkdate error? The following bit of code completely baffles me as to why it doesn't work. I am doing a very simple validation where I check to see if the end date field of an inputted record is an older date than the start date. I checked this by putting in the same date for both end and start dates. Yet mkdate gives me a different value for each even though since they are both the same date, I should get the same value returned. Right? //notice the start and end date is the same. Therefore, you should get the same value for each, right? START LITTLE CODE SNIPPET $parsed_start_date=split(/, 08/02/2002); $parsed_end_date=split(/, 08/02/2002); $start_dts = mktime(, , , $parsed_start_date[0], $parsed_start_date[1], $parsed_start_date[2]); $end_dts = mktime(, , , $parsed_end_date[0], $parsed_end_date[1], $parsed_date[2]); if ($start_dts $end_dts) { echo This function thinks the end date is older than the start date.; } else { echo Whoah, it actually worked.; } END LITTLE CODE SNIPPET What am I not seeing? Thanks in advance, J. Chyun -- 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] mkdate error?
YOU use $parsed_date[2] in stead of $parsed_end_date[2] Op maandag 12 augustus 2002 00:01, schreef jc: The following bit of code completely baffles me as to why it doesn't work. I am doing a very simple validation where I check to see if the end date field of an inputted record is an older date than the start date. I checked this by putting in the same date for both end and start dates. Yet mkdate gives me a different value for each even though since they are both the same date, I should get the same value returned. Right? //notice the start and end date is the same. Therefore, you should get the same value for each, right? START LITTLE CODE SNIPPET $parsed_start_date=split(/, 08/02/2002); $parsed_end_date=split(/, 08/02/2002); $start_dts = mktime(, , , $parsed_start_date[0], $parsed_start_date[1], $parsed_start_date[2]); $end_dts = mktime(, , , $parsed_end_date[0], $parsed_end_date[1], $parsed_date[2]); if ($start_dts $end_dts) { echo This function thinks the end date is older than the start date.; } else { echo Whoah, it actually worked.; } END LITTLE CODE SNIPPET What am I not seeing? Thanks in advance, J. Chyun -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mkdate error?
Oh my God. I had redone and ripped this apart for hours. Errors like this make me realize how stupid I truly am. Thank you for your help. :) I can go on with life now. J. Chyun At 12:30 AM 8/12/2002 +0200, Bas Jobsen wrote: YOU use $parsed_date[2] in stead of $parsed_end_date[2] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php