API16

Difference between revisions of "JDate/ construct"

From Joomla! Documentation

< API16:JDate
(New page: ===Description=== Constructor. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{De...)
 
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>[[Description:JDate/__construct|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JDate/__construct}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 72: Line 72:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JDate/__construct|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JDate/__construct}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 87: Line 87:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Revision as of 22:03, 12 May 2013

The "API16" 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]

Constructor.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

__construct($date= 'now', $tz=null)
Parameter Name Default Value Description
$date 'now' String in a format accepted by strtotime(), defaults to "now".
$tz null Time zone to be used for the date.

Returns[edit]

void

Defined in[edit]

libraries/joomla/utilities/date.php

Importing[edit]

jimport( 'joomla.utilities.date' );

Source Body[edit]

public function __construct($date = 'now', $tz = null)
{
        // Create the base GMT and server time zone objects.
        if (empty(self::$gmt) || empty(self::$stz))
        {
                self::$gmt = new DateTimeZone('GMT');
                self::$stz = new DateTimeZone(@date_default_timezone_get());
        }

        // If the time zone object is not set, attempt to build it.
        if (!$tz instanceof DateTimeZone)
        {
                if($tz === null) {
                        $tz = self::$gmt;
                }
                // Translate from offset.
                elseif (is_numeric($tz)) {
                        $tz = new DateTimeZone(self::$offsets[(string) $tz]);
                }
                elseif (is_string($tz)) {
                        $tz = new DateTimeZone($tz);
                }
        }

        // If the date is numeric assume a unix timestamp and convert it.
        $date = is_numeric($date) ? date('c', $date) : $date;

        // Call the DateTime constructor.
        parent::__construct($date, $tz);

        // Set the timezone object for access later.
        $this->_tz = $tz;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />