note 101509 added to function.px-date2string
| From: | john dot navratil at sbcglobal dot net | Date: | Tue, 21 Dec 2010 17:52:48 +0000 |
| Subject: | note 101509 added to function.px-date2string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175113@lists.php.net to get a copy of this message | ||
Date fields are retrieved as the number of days since 0 A.D. (I think), but not as anything
resembling a date. If you are exporting this data, you must used this function to convert. Read
the schema first to determine which fields are date fields...
$schema = $pxdoc->get_schema();
$dateFields = array();
foreach ($schema as $key => $attrs) {
if ($attrs["type"] == PX_FIELD_DATE) // Collect list of "date" columns
$dateFields[] = $key;
}
An export to a CSV format, for example, could them be written...
for ($rec = 0; $rec < $totRecs; ++$rec) {
$arr = $pxdoc->get_record($rec);
foreach ($dateFields as $key) {
$arr[$key] = $pxdoc->date2string($arr[$key], "m/d/Y");
}
fputcsv(STDOUT, $arr); // STDOUT only available with CLI
}
----
Server IP: 64.71.164.2
Probable Submitter: 70.138.54.128
----
Manual Page -- http://www.php.net/manual/en/function.px-date2string.php
Edit -- https://master.php.net/note/edit/101509
Del: integrated -- https://master.php.net/note/delete/101509/integrated
Del: useless -- https://master.php.net/note/delete/101509/useless
Del: bad code -- https://master.php.net/note/delete/101509/bad+code
Del: spam -- https://master.php.net/note/delete/101509/spam
Del: non-english -- https://master.php.net/note/delete/101509/non-english
Del: in docs -- https://master.php.net/note/delete/101509/in+docs
Del: other reasons-- https://master.php.net/note/delete/101509
Reject -- https://master.php.net/note/reject/101509
Search -- https://master.php.net/manage/user-notes.php