Problem with strtostring() & date()Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pkvasan
Forum Newbie
Posts: 4
Joined: Mon Jan 29, 2007 6:05 am

Problem with strtostring() & date()Function

Post 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]
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

Try this format mm-dd-yyyy

Code: Select all

$str = '2/12/2006';
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Do

Code: Select all

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