chanchelkumar Posted October 5, 2009 Share Posted October 5, 2009 Hi all. Am trying to display the date, while i trying it in my windows machine having php 5 in it doesn't show any problem,, But in my site , it is having php4 in init displays the date incorrect.. am using this code.. echo "<br>dtStr ".$date=strtotime(implode("-",explode("/",$_REQUEST['date1']))); echo "<br>o/p ".date("D M d, Y",$date); am taking the date value from a javascript calender .. Please help me... Thanks in advance.. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 displays the date incorrect..You would need to provide an example of what you are getting and tell us what it should be. Quote Link to comment Share on other sites More sharing options...
shawnplr Posted October 5, 2009 Share Posted October 5, 2009 echo date('l jS \of F Y'); Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted October 5, 2009 Author Share Posted October 5, 2009 i/p ie 05/10/2009 dtStr 1301616000 o/p Fri Apr 01, 2011 the o/p is to be Oct 05, 2009 it is showing correct in my php5 installed machine.. Quote Link to comment Share on other sites More sharing options...
cags Posted October 5, 2009 Share Posted October 5, 2009 Just out of interest what result do you get if you use this... $parts = explode("05/10/2009"); $day = $parts[0]; $month = $parts[1]; $year = $parts[2]; echo date("D M d, Y", strtotime($year . "-" . $month . "-" . $day)); Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 Have you echoed $_REQUEST['date1'] right before that code, because it is more likely that you have a same name post/get/cookie that is overwriting the value or that register_globals are on and you have a session variable by that same name that is overwriting the value. A) You should not use $_REQUEST (ever). Use the correct $_POST, $_GET, or $_COOKIE that you expect a value in, B) If register_globals are ON, you should know which of your servers have them on and be aware that they cause same name variables to all be cross-populated. Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted October 5, 2009 Author Share Posted October 5, 2009 thanks PFMaBiSmAd .. . i changed it to $_POST and checked register_globals it is off... What will be my error?? any problem using in strtotime ().. in the php versions.. Have you echoed $_REQUEST['date1'] right before that code, because it is more likely that you have a same name post/get/cookie that is overwriting the value or that register_globals are on and you have a session variable by that same name that is overwriting the value. A) You should not use $_REQUEST (ever). Use the correct $_POST, $_GET, or $_COOKIE that you expect a value in, B) If register_globals are ON, you should know which of your servers have them on and be aware that they cause same name variables to all be cross-populated. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 1301616000 produces an 2011 date on my php5 system, so there is something wrong with the output from the strtotime(). Is the server's date/time set correctly? Also, I would not put an assignment statement as part of an echo statement. 05/10/2009 produces a Unix Timestamp in the vicinity of 1254722400 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 The formats containing a "-" that strtotime() understands are - 1972-09-24 # ISO 8601. 72-9-24 # Assume 19xx for 69 through 99, # 20xx for 00 through 68. 72-09-24 # Leading zeros are ignored. 24-sep-72 I have seen the 24-sep-72 format work where 'sep' is actually the month number (probably under php5), but you have likely come across a case where the strtotime() function was 'enhanced' under php5. You can ultimately fix this so that it will always work by rearranging the fields to match the first format on that list. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 Here is a bug report where php had support for the mm-dd-yyyy format at some point, it was removed, then added back in - http://bugs.php.net/bug.php?id=36396 I did not find anything specific where support for that format was first added. [Edit: php.net, it's kind of hard using undocumented features in a programming language.] Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 5, 2009 Share Posted October 5, 2009 Correction to the above post - mm-dd-yyyy should have been dd-mm-yyyy Quote Link to comment Share on other sites More sharing options...
chanchelkumar Posted October 12, 2009 Author Share Posted October 12, 2009 thanks PFMaBiSmAd.. U really help me a lot on this issue.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.