jDateTime::strftime PHP Method

strftime() public static method

Format a local time/date according to locale settings built in strftime() function. e.g: $obj->strftime("%x %H", time()); $obj->strftime("%H", time(), false, false, 'America/New_York');
Author: Omid Pilevar
public static strftime ( $format, $stamp = false, $convert = null, $jalali = null, $timezone = null ) : string
$format string Acceps format string based on: php.net/date
$stamp int Unix Timestamp (Epoch Time)
$convert bool (Optional) forces convert action. pass null to use system default
$jalali bool (Optional) forces jalali conversion. pass null to use system default
$timezone string (Optional) forces a different timezone. pass null to use system default
return string Formatted input
    public static function strftime($format, $stamp = false, $convert = null, $jalali = null, $timezone = null)
    {
        $str_format_code = array('%a', '%A', '%d', '%e', '%j', '%u', '%w', '%U', '%V', '%W', '%b', '%B', '%h', '%m', '%C', '%g', '%G', '%y', '%Y', '%H', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X', '%z', '%Z', '%c', '%D', '%F', '%s', '%x', '%n', '%t', '%%');
        $date_format_code = array('D', 'l', 'd', 'j', 'z', 'N', 'w', 'W', 'W', 'W', 'M', 'F', 'M', 'm', 'y', 'y', 'y', 'y', 'Y', 'H', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'h:i:s', 'H', 'H', 'D j M H:i:s', 'd/m/y', 'Y-m-d', 'U', 'd/m/y', '\\n', '\\t', '%');
        //Change Strftime format to Date format
        $format = str_replace($str_format_code, $date_format_code, $format);
        //Convert to date
        return self::date($format, $stamp, $convert, $jalali, $timezone);
    }

Usage Example

Beispiel #1
0
 public function format($str, $convert = true)
 {
     // convert alias string
     if (in_array($str, array_keys($this->formats))) {
         $str = $this->formats[$str];
     }
     // if valid unix timestamp...
     if ($this->time !== false) {
         return jDateTime::strftime($str, $this->time, $convert);
     } else {
         return false;
     }
 }
All Usage Examples Of jDateTime::strftime