datetime::createFromFormat

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
RussellEngland
Forum Newbie
Posts: 8
Joined: Thu Nov 11, 2010 3:58 pm

datetime::createFromFormat

Post by RussellEngland »

If I use

Code: Select all

echo showlocaltime('31/12/2011');
showlocaltime($localtime)
{
    $localformat='d/m/Y H:i:s';
    $servertime = new DateTime(null);
    $servertime->createFromFormat($localformat, $localtime);
    echo var_dump(DateTime::getLastErrors());
    // return($servertime->format(DATE_ISO8601));
}
Then I get an error saying missing data.

Code: Select all

array(4) { ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(1) ["errors"]=> array(1) { [10]=> string(12) "Data missing" } } from locale to server 
$localtime is an argument, I won't know if its a date, time or date+time.

Is there a way around this so that the time will default to 00:00:00?

Many thanks.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: datetime::createFromFormat

Post by Jade »

Post Reply