我的代码不会以法语输出星期几。注意:我还尝试用相同的结果翻译代码中的星期几(仅以英文输出)。
date_default_timezone_set('America/New_York');
setlocale (LC_TIME, 'fr_FR.utf8','fra');
$today = strtotime('Saturday 14:00');
$tomorrow = strtotime('Saturday 14:00');
$friday = strtotime('Friday 14:00');
$sunday = strtotime('Sunday 24:00');
$now = time();
if($now < $friday && $now > $sunday)
{
$timeLeft = ($now > $today ? $tomorrow : $today) - $now;
$hoursLeft = gmdate("G", $timeLeft);
$minutesLeft = gmdate("i", $timeLeft);
$secondsLeft = gmdate("s", $timeLeft);
if($hoursLeft > 0)
{
echo $hoursLeft . ' heur';
if($minutesLeft > 0)
{
echo ' et ' . $minutesLeft . ' minutes';
}
}
else
{
echo $minutesLeft . ' minutes et ' . $secondsLeft . ' seconde ';
}
}
else
$date = date("l\, F j", strtotime("tomorrow"));
$day = date('l', strtotime('today'));
if ($day == 'Friday')
{
if($now > strtotime('Friday 14:00'))
{
echo date('l, F j', strtotime('Tuesday'));
}
elseif($now < strtotime('Friday 14:00'))
{
echo date('l, F j', strtotime('Monday'));
}
}
elseif ($day == 'Saturday' || $day == 'Sunday')
{
echo date('l, F j', strtotime('Tuesday'));
}
但是,如果我在上面单独使用这个基本代码,它会正确显示:
setlocale (LC_TIME, 'fr_FR.utf8','fra');
echo (strftime("%A %d %B"));
如何让第一个块仅以法语输出?