Page 1 of 1

Problem with strtostring() & date()Function

Posted: Mon Jun 25, 2007 9:10 am
by pkvasan
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Forums 

I am using date & strtotime function in my codes 

I had given input as "12-02-2006" in  php ver 5.2.1 the output produced is 12-02-2006 == Sunday 12th of February 2006 12:00:00 AM

With the same input if i test in php ver 4.3.1.1 the output produced is 12-02-2006 == Saturday 29th of July 2017 12:00:00 AM

Can any one help me what is problem here is it my code is mentioned below

Code: Select all

<?
$str = '12-02-2006';


if (($timestamp = strtotime($str)) === false) {
    echo "The string ($str) is in valid";
} else {
    echo "$str == " . date('l dS \o\f F Y h:i:s A', $timestamp);
}
?>
Thanks & Regards

PKVASAN


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Jun 25, 2007 9:44 am
by mentor
Try this format mm-dd-yyyy

Code: Select all

$str = '2/12/2006';

Posted: Mon Jun 25, 2007 1:23 pm
by RobertGonzalez
Do

Code: Select all

<?php
echo time();
?>
On both systems at about the same time to see what each is returning.