PHP Classes

Some information

Recommend this page to a friend!

      Ultimate Date Parser  >  All threads  >  Some information  >  (Un) Subscribe thread alerts  
Subject:Some information
Summary:Some informatio
Messages:4
Author:----
Date:2009-07-10 09:04:01
Update:2012-03-22 16:10:49
 

 


  1. Some information   Reply   Report abuse  
Picture of ---- ---- - 2009-07-10 09:04:01
I teste this code with your class
.............
$data1="2001-10-12";
$data2="26-02-1985";
$sd= new simpledatetime();


$arr=$sd->parseDate("Y-m-d",$data1);
print_r($arr);
if(is_null($arr["Hour"])){
echo "no hour";
}

$arr=$sd->parseDate("d-m-Y",$data2);
print_r($arr);
if(is_null($arr["Hour"])){
echo "no hour";
}

echo $sd->Format("d-m-Y","Y-m-d",$data1);

echo $sd->Format("Y/m/d","d-m-Y",$data2);


.....

so I discovered that the are no values stored in Hour , Minutes Second, anyway store a 0h:0m:0s can be useful to avoid problem.

so i modded your class editing the end return of parseDate

//set unset value
if(is_null($resultvar["Hour"])) {
$resultvar["Hour"]=0;
}
if(is_null($resultvar["Minute"])) {
$resultvar["Minute"]=0;
}
if(is_null($resultvar["Second"])) {
$resultvar["Second"]=0;
}
if(is_null($resultvar["Year"])) {
$resultvar["Year"]=2000;
}
if(is_null($resultvar["Month"])) {
$resultvar["Month"]=01;
}
if(is_null($resultvar["Day"])) {
$resultvar["Day"]=01;
}




return ($localize)?$this->Localize($resultvar):$resultvar;

  2. Re: Some information   Reply   Report abuse  
Picture of ---- ---- - 2009-07-10 09:55:08 - In reply to message 1 from ----
i have a problem creating reformatting the date 01 01 1970 it'st parsed correctly but php

Warning: mktime() [function.mktime]: Windows does not support negative values for this function in simpledatetime.php on line 294

Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in simpledatetime.php on line 294

ok but the date is exactly (00:00:00), January 1, 1970 not prior

  3. Bugged regexp   Reply   Report abuse  
Picture of MadMind MadMind - 2009-07-22 13:49:22 - In reply to message 2 from ----
The G parameter generates a strange regexp ([0-23]) that fails to parse date.
A quick fix: around line 50 in var $types=array set "G"=>"([0-9]|1[0-9]|2[0-3])",

  4. Re: Some information   Reply   Report abuse  
Picture of Taha Paksu Taha Paksu - 2012-03-22 16:10:49 - In reply to message 3 from MadMind
Thanks Babbo and MadMind, I've made those changes and added your names in the script as contributors. And I've added an example file for year 1968.