Jump to content

I'm going nuts!


iPixel

Recommended Posts

Can anyone tell me why $new_sDate ends up empty!?

$search_sDate = $_GET['sDate']; #03-01-2010

#recreate dates for Oracle format

$s_sD = explode("-",$search_sDate);

	if($s_sD[0] == 01) $new_sDate = $s_sD[1] . "-" . "JAN" . "-" . $s_sD[2];
	if($s_sD[0] == 02) $new_sDate = $s_sD[1] . "-" . "FEB" . "-" . $s_sD[2];
	if($s_sD[0] == 03) $new_sDate = $s_sD[1] . "-" . "MAR" . "-" . $s_sD[2];
	if($s_sD[0] == 04) $new_sDate = $s_sD[1] . "-" . "APR" . "-" . $s_sD[2];
	if($s_sD[0] == 05) $new_sDate = $s_sD[1] . "-" . "MAY" . "-" . $s_sD[2];
	if($s_sD[0] == 06) $new_sDate = $s_sD[1] . "-" . "JUN" . "-" . $s_sD[2];
	if($s_sD[0] == 07) $new_sDate = $s_sD[1] . "-" . "JUL" . "-" . $s_sD[2];
	if($s_sD[0] == 08) $new_sDate = $s_sD[1] . "-" . "AUG" . "-" . $s_sD[2];
	if($s_sD[0] == 09) $new_sDate = $s_sD[1] . "-" . "SEP" . "-" . $s_sD[2];
	if($s_sD[0] == 10) $new_sDate = $s_sD[1] . "-" . "OCT" . "-" . $s_sD[2];
	if($s_sD[0] == 11) $new_sDate = $s_sD[1] . "-" . "NOV" . "-" . $s_sD[2];
	if($s_sD[0] == 12) $new_sDate = $s_sD[1] . "-" . "DEC" . "-" . $s_sD[2];

	echo $new_sDate;

 

Thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/213394-im-going-nuts/
Share on other sites

Obviously because $s_sD[0] never equals any of the values your looking for.

 

You really ought to look at the date functions anyway, you have allot of redundant code.

 

Actually $s_sD always equals the values i'm looking for, i echoes those separately before i test them and they always return a correct value. It's just $new_sDate that gives me the issue, the weirdest thing is that this used to work and just decided to annoy me right now.

Link to comment
https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111007
Share on other sites

Are you testing with an 08 or 09 month value?

 

Be advised that leading zeros on numbers cause php to treat them as octal and 08 and 09 are invalid octal values.

 

You would want to enclose the values in quotes so that they are treated as strings, especially the '08' and '09'.

Link to comment
https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111013
Share on other sites

Are you testing with an 08 or 09 month value?

 

Be advised that leading zeros on numbers cause php to treat them as octal and 08 and 09 are invalid octal values.

 

You would want to enclose the values in quotes so that they are treated as strings, especially the '08' and '09'.

 

LOL that worked, funny cause i bothered trying to do "08" with double quotes and that still failed, i guess single quotes do the trick!

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/213394-im-going-nuts/#findComment-1111016
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.