Quantcast
Channel: PHP – PHP-Function Blog
Viewing all articles
Browse latest Browse all 18

PHP-Funktion strftime_win()

$
0
0
Diese Funktion ermöglicht die Ausführung von strftime unter Windows, da hier nicht alle Funktionen zur Verfügung stehen.
<?php
/**
 *   Diese Funktion ermöglicht die Ausführung von strftime unter Windows, da hier nicht alle
 *   Funktionen zur Verfügung stehen.
 *
 *   @param string $format [, int $timestamp = NULL]
 *   @return string
 *   @see http://www.php-function.de/funktion/datum-und-zeit/strftime_win/
 */
function strftime_win($format, $timestamp = NULL){
   if (!$timestamp) $timestamp = time();
   $replaces = array(
      '%u' => ($w = date("w", $timestamp)) ? $w : 7,
      '%e' => sprintf("%' 2d", date("j", $timestamp)),
      '%C' => sprintf("%02d", date("Y", $timestamp) / 100),
      '%r' => date("h:i:s", $timestamp) . " %p",
      '%R' => date("H:i", $timestamp),
      '%T' => '%H:%M:%S',
      '%D' => '%m/%d/%y',
      '%h' => '%b',
      '%n' => "\n",
      '%t' => "\t"
   );
   $format = strtr($format, $replaces);
   return strftime($format, $timestamp);
}
?>

 

Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles