Ignore:
Timestamp:
01/29/14 21:50:58 (6 years ago)
Author:
mistic100
Message:

Merged revision(s) 27043 from trunk:
str2DateTime return false on empty input

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/include/functions.inc.php

    r26903 r27044  
    545545function str2DateTime($original, $format=null) 
    546546{ 
    547   if ( !empty($format) && version_compare(PHP_VERSION, '5.3.0') >= 0 )// from known date format 
     547  if (empty($original)) 
     548  { 
     549    return false; 
     550  } 
     551 
     552  if (!empty($format) && version_compare(PHP_VERSION, '5.3.0') >= 0)// from known date format 
    548553  { 
    549554    return DateTime::createFromFormat('!'.$format, $original); // ! char to reset fields to UNIX epoch 
     
    554559    if (empty($t)) // from timestamp 
    555560    { 
    556       $date = new DateTime('@'.$original); 
     561      return new DateTime('@'.$original); 
    557562    } 
    558563    else // from unknown date format (assuming something like Y-m-d H:i:s) 
     
    574579      $date->setDate($ymdhms[0], $ymdhms[1], $ymdhms[2]); 
    575580      $date->setTime($ymdhms[3], $ymdhms[4], $ymdhms[5]); 
    576     } 
    577      
    578     return $date; 
     581      return $date; 
     582    } 
    579583  } 
    580584} 
Note: See TracChangeset for help on using the changeset viewer.