Jump to content

Recommended Posts

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..

Link to comment
https://forums.phpfreaks.com/topic/176549-solved-date-displaying-error/
Share on other sites

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.

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.

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

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.

 

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.]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.