Home » Database » DB_DataObject_FormBuilder » Bug #2375
Array2Date & Date2Array
Details
| Request #2375 | Array2Date & Date2Array |
|---|---|
| Submitted | 2004-09-22 17:12 UTC |
| From | dvilches at info dot unlp dot edu dot ar |
| Assigned | justinpatrin |
| Status | Closed |
| Package | DB_DataObject_FormBuilder |
| PHP Version | 5.0.1 |
| OS | windows |
| Roadmaps | (Not assigned) |
Comments
[2004-09-22 17:12 UTC] dvilches at info dot unlp dot edu dot ar
Description:
------------
I changed the following functions _array2date and _date2array, because there was trouble with this date format: d/F/Y
function _date2array($date)
{
$da = array();
if (is_string($date)) {
// Get PEAR::Date class definition, if needed
include_once('Date.php');
$dObj = new Date($date);
$da['d'] = $dObj->getDay();
$da['m'] = $dObj->getMonth();
$da['M'] = $dObj->getMonth();
$da['F'] = $dObj->getMonth(); //added
$da['Y'] = $dObj->getYear();
$da['H'] = $dObj->getHour();
$da['i'] = $dObj->getMinute();
$da['s'] = $dObj->getSecond();
unset($dObj);
} else {
if (is_int($date)) {
$time = $date;
} else {
$time = time();
}
$da['d'] = date('d', $time);
$da['m'] = date('m', $time);
$da['M'] = date('m', $time);
$da['F'] = date('m', $time); //added
$da['Y'] = date('Y', $time);
$da['H'] = date('H', $time);
$da['i'] = date('i', $time);
$da['s'] = date('s', $time);
}
$this->debug("<i>_date2array():</i> from $date ...");
return $da;
}
function _array2date($dateInput, $timestamp = false)
{
if (isset($dateInput['M'])) {
$month = $dateInput['M'];
} elseif (isset($dateInput['m'])) {
$month = $dateInput['m'];
} elseif (isset($dateInput['F'])) { //added
$month = $dateInput['F']; //added
}
$strDate = "";
if (isset($dateInput['Y']) && isset($month) && isset($dateInput['d'])) {
$strDate .= sprintf('%s-%s-%s', $dateInput['Y'], $month, $dateInput['d']);
}
if (isset($dateInput['H']) && isset($dateInput['i']) && isset($dateInput['s'])) {
if (!empty($strDate)) {
$strDate .= " ";
}
$strDate .= sprintf('%s:%s:%s', $dateInput['H'], $dateInput['i'], $dateInput['s']);
}
$this->debug("<i>_array2date():</i> to $strDate ...");
return $strDate;
}
Thanks You,
Diego Vilches
[2004-09-22 17:26 UTC] drigani at sinectis dot com dot ar
You can tell me what are the problem with the format date?
Thank you.
Diego Drigani
[2004-09-22 17:29 UTC] drigani at sinectis dot com dot ar
You can tell me what are the problem with the format date?
Thank you.
Diego Drigani
[2004-09-22 17:37 UTC] dvilches at info dot unlp dot edu dot ar
This problem ocurrs when the database table have a DateTime field and the Data_Object.ini file is set to [DB_DataObject_FormBuilder] dateElementFormat = d/F/Y
The problem in this case, the date field is displays bad and this produce too, problems at update and insert.
Sorry bye my little english...
[2004-09-30 19:30 UTC] dvilches at info dot unlp dot edu dot ar
what i mean is that it need to be compatibility with HTML_QuickForm_Date:
i attach format used by HTML_QuickForm_Date:
'format': Format of the date, based on PHP's date() function.
The following characters are recognised in format string:
D => Short names of days
l => Long names of days
d => Day numbers
M => Short names of months
F => Long names of months
m => Month numbers
Y => Four digit year
y => Two digit year
h => 12 hour format
H => 23 hour format
i => Minutes
s => Seconds
a => am/pm
A => AM/PM
Thank!
[2004-12-10 16:20 UTC] dvilches at info dot unlp dot edu dot ar
Is my pleasure to collaborate with the pear community.
Thanks you!!