%m.%y 01.01.70
DATE_FORMAT_JS1 y-m-d 1970-01-01
The DATE_FORMAT_JS1 format is slightly different from the other
formats. It is to be used with JavaScript, not JDate or PHP date functions.
This example demonstrates how we use DATE_FORMAT_LC2:
// LC2
$lc2 = $date->toFormat(JText::_('DATE_FORMAT_LC2'));
Notice that we use JText to translate the date format before passing it
to the JDate toFormat() method. This is what translates the format
string to the current locale format. Remember that, although the syntax
suggests it, the date format names are not PHP constants.
If we want to use a format that is not described by any of the above formats, we
should consider adding the format to the language file that our extension uses.
The last method we will discuss is the setOffset() method. This method is used to
apply an offset to the date when it is passed through the toFormat() method. To apply
the offset UTC+2 to a date and time before we display it, we would do the following:
$date->setOffset(2);
Utilities and Useful Classes
[ 344 ]
Notice that the offset is specified in hours.
Pages:
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476