Difference between revisions of "JFactory/getDate"
From Joomla! Documentation
< API15:JFactory
(New page: ===Description===
Return a reference to the JDate object
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]<...) |
m (removing red link to edit, no existant pages) |
||
Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 81: | Line 81: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 96: | Line 96: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API15]] |
Revision as of 11:50, 12 May 2013
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Return a reference to the JDate object
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
& getDate($time= 'now', $tzOffset=0)
Parameter Name | Default Value | Description |
---|---|---|
$time | 'now' | $time The initial time for the object |
$tzOffset | 0 | $tzOffset The timezone offset. |
Returns[edit]
object
Defined in[edit]
libraries/joomla/factory.php
Importing[edit]
jimport( 'joomla.factory' );
Source Body[edit]
function &getDate($time = 'now', $tzOffset = 0)
{
jimport('joomla.utilities.date');
static $instances;
static $classname;
static $mainLocale;
if(!isset($instances)) {
$instances = array();
}
$language =& JFactory::getLanguage();
$locale = $language->getTag();
if(!isset($classname) || $locale != $mainLocale) {
//Store the locale for future reference
$mainLocale = $locale;
$localePath = JPATH_ROOT . DS . 'language' . DS . $mainLocale . DS . $mainLocale . '.date.php';
if($mainLocale !== false && file_exists($localePath)) {
$classname = 'JDate'.str_replace('-', '_', $mainLocale);
JLoader::register( $classname, $localePath);
if(!class_exists($classname)) {
//Something went wrong. The file exists, but the class does not, default to JDate
$classname = 'JDate';
}
} else {
//No file, so default to JDate
$classname = 'JDate';
}
}
$key = $time . '-' . $tzOffset;
if(!isset($instances[$classname][$key])) {
$tmp = new $classname($time, $tzOffset);
//We need to serialize to break the reference
$instances[$classname][$key] = serialize($tmp);
unset($tmp);
}
$date = unserialize($instances[$classname][$key]);
return $date;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />