Code solutions to PHP, JS, CSSCode source PHP, JS, CSS

Spread your code soluces to the world

Love me
Solucior » PHP » Display a date in French

Display a date in French

06/11/2011 by Dux   -   5/5 (2 ratings)

Function gdhfr for "Groupe Date Heure France" shows the date and time in the french format.

mixed gdhfr ( int $timestamp = time() [, bool $hm = false [ , bool $s = false ] ] )

$timestamp = UNIX time
$hm = when set to TRUE, displays hours and minutes
$s = when set to TRUE, displays seconds

source code



 
<?php

function gdhfr ($utime, $hm = FALSE, $s = FALSE)
{
   
$jours = array("", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche");
   
$mois = array("", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
   
   
$return = $jours[date("w", $utime)].' '.date("d", $utime).' '.$mois[date("n", $utime)].' '.date("Y", $utime);
   if (
$hm) $return .= ' '.date("H:m", $utime);
   if (
$hm && $s) $return .= date(":s", $utime);
   return
$return;
}


echo
gdhfr (1307784249, true, true);
// samedi 11 juin 2011 11:06:09

echo gdhfr (1307784249);
// samedi 11 juin 2011

?>
Rate this code     |     Copied : 57x

Comments for Display a date in French

eliphas     10/26/2011 12:14
good and easy to use thanks.
Add a comment Nickname
ZOOM