Date formats in PDF [message #1603] |
Thu, 04 September 2008 11:19 |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
I'm trying to print reports via the PDF output, but am having a problem getting the date format correct.
The config.inc file has
// set date format - choose one of the following
$GLOBALS['date_format'] = 'dmy';
//$GLOBALS['date_format'] = 'mdy';
//$GLOBALS['date_format'] = 'ymd';
and I am seeing the correct date format on the screens. However, in the reports dates are showing as YYYY-MM-DD. Could something be overriding the config.inc?
Also, is it possible to specify any other date formats for printing, e.g. dd/mm/yy ?
Graham
|
|
|
Re: Date formats in PDF [message #1604 is a reply to message #1603] |
Thu, 04 September 2008 13:48 |
AJM
Messages: 2370 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have just tried this using the PERSON table in the XAMPLE application (which is included in the Radicore download) and what comes out in the PDF document is exactly the same as what is shown in the screen. Both times the standard formatData() method inside 'std.table.class.inc' is called.
I have tried changing the date format in the config.inc file and it works as expected. If it doesn't work for you then I suggest that you step through with your debugger to see why the date formatting function is not being called.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Date formats in PDF [message #1606 is a reply to message #1605] |
Fri, 05 September 2008 04:57 |
AJM
Messages: 2370 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You need to step through with your debugger to see what happens when the formatData() method is called. This is supposed to take each field and format it for output. It works for me when I test it, so why isn't it working for you? This is where having a debugger can saves hours of fruitless guessing and searching -simply step through the code as it is being executed and you will see what happens and where it happens.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Date formats in PDF [message #1608 is a reply to message #1607] |
Fri, 05 September 2008 12:23 |
AJM
Messages: 2370 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
The formatData() method can only format dates for those fields in $this->fieldspec which are actually identified as dates. If you are bringing in fields from other tables via a JOIN then those fields will not have any entries in $this->fieldspec, therefore there is no information on how they should be formatted.
The solution is simple - insert code into the _cm_changeConfig() method to temporarily add the fields you want formatted using code similar to the following:
$this->fieldspec['date_field'] = array('type' => 'date');
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
|