DatePeriod not setting the timezone [duplicate]
This question already has an answer here:
PHP strftime outputs wrong format despite correct timezone
3 answers
I am creating a DatePeriod
and I want to show the names of months and days in French:
$timeZoneParis = new DateTimeZone('Europe/Paris');
$dateDebutCalendrier = new DateTime('2018-11-01', $timeZoneParis);
$dateFinCalendrier = new DateTime('2018-11-31', $timeZoneParis);
$period = new DatePeriod($dateDebutCalendrier,new DateInterval('P1D'),$dateFinCalendrier);
Expected result:
Janvier, Fevrier...
Actual result:
January, February...
php date timezone
marked as duplicate by Matt Johnson
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 22:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 1 more comment
This question already has an answer here:
PHP strftime outputs wrong format despite correct timezone
3 answers
I am creating a DatePeriod
and I want to show the names of months and days in French:
$timeZoneParis = new DateTimeZone('Europe/Paris');
$dateDebutCalendrier = new DateTime('2018-11-01', $timeZoneParis);
$dateFinCalendrier = new DateTime('2018-11-31', $timeZoneParis);
$period = new DatePeriod($dateDebutCalendrier,new DateInterval('P1D'),$dateFinCalendrier);
Expected result:
Janvier, Fevrier...
Actual result:
January, February...
php date timezone
marked as duplicate by Matt Johnson
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 22:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I'm not sure what you mean by "the good time zone"? Can you edit your question to clarify 1. what result you are getting and 2. what result you expect? You're not passing aDateTimeZone
to$lastDayThisMonth
- is this intentional, or an omission?
– Darragh Enright
Nov 23 '18 at 11:23
@DarraghEnright not intentional, i've changed my code to a better format and updated my question :)
– Projet Sin
Nov 23 '18 at 11:29
I understand now. This is not something you can configure or control directly usingDateTime
andDatePeriod
- this is a locale based question, andDateTime
does not honour locales. You have a few choices, includingIntlDateFormatter
if you have it installed, orstrftime()
. Here are some helpful answers
– Darragh Enright
Nov 23 '18 at 11:43
I tried this : echo strftime("%d %B", $dateDebutCalendrier->getTimestamp()); but this is still in English
– Projet Sin
Nov 23 '18 at 13:05
@ProjetSin - Check out the dup question, which bears an uncanny resemblance to yours, asked one week earlier. Are you and that author (kalvn) associated in some way? This seems like another case of StackOverflow déjà-vu... Can you shed some light on this phenomenon? Thanks.
– Matt Johnson
Nov 26 '18 at 22:25
|
show 1 more comment
This question already has an answer here:
PHP strftime outputs wrong format despite correct timezone
3 answers
I am creating a DatePeriod
and I want to show the names of months and days in French:
$timeZoneParis = new DateTimeZone('Europe/Paris');
$dateDebutCalendrier = new DateTime('2018-11-01', $timeZoneParis);
$dateFinCalendrier = new DateTime('2018-11-31', $timeZoneParis);
$period = new DatePeriod($dateDebutCalendrier,new DateInterval('P1D'),$dateFinCalendrier);
Expected result:
Janvier, Fevrier...
Actual result:
January, February...
php date timezone
This question already has an answer here:
PHP strftime outputs wrong format despite correct timezone
3 answers
I am creating a DatePeriod
and I want to show the names of months and days in French:
$timeZoneParis = new DateTimeZone('Europe/Paris');
$dateDebutCalendrier = new DateTime('2018-11-01', $timeZoneParis);
$dateFinCalendrier = new DateTime('2018-11-31', $timeZoneParis);
$period = new DatePeriod($dateDebutCalendrier,new DateInterval('P1D'),$dateFinCalendrier);
Expected result:
Janvier, Fevrier...
Actual result:
January, February...
This question already has an answer here:
PHP strftime outputs wrong format despite correct timezone
3 answers
php date timezone
php date timezone
edited Nov 23 '18 at 11:47
Darragh Enright
9,79553140
9,79553140
asked Nov 23 '18 at 11:19
Projet SinProjet Sin
757
757
marked as duplicate by Matt Johnson
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 22:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Matt Johnson
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 26 '18 at 22:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I'm not sure what you mean by "the good time zone"? Can you edit your question to clarify 1. what result you are getting and 2. what result you expect? You're not passing aDateTimeZone
to$lastDayThisMonth
- is this intentional, or an omission?
– Darragh Enright
Nov 23 '18 at 11:23
@DarraghEnright not intentional, i've changed my code to a better format and updated my question :)
– Projet Sin
Nov 23 '18 at 11:29
I understand now. This is not something you can configure or control directly usingDateTime
andDatePeriod
- this is a locale based question, andDateTime
does not honour locales. You have a few choices, includingIntlDateFormatter
if you have it installed, orstrftime()
. Here are some helpful answers
– Darragh Enright
Nov 23 '18 at 11:43
I tried this : echo strftime("%d %B", $dateDebutCalendrier->getTimestamp()); but this is still in English
– Projet Sin
Nov 23 '18 at 13:05
@ProjetSin - Check out the dup question, which bears an uncanny resemblance to yours, asked one week earlier. Are you and that author (kalvn) associated in some way? This seems like another case of StackOverflow déjà-vu... Can you shed some light on this phenomenon? Thanks.
– Matt Johnson
Nov 26 '18 at 22:25
|
show 1 more comment
I'm not sure what you mean by "the good time zone"? Can you edit your question to clarify 1. what result you are getting and 2. what result you expect? You're not passing aDateTimeZone
to$lastDayThisMonth
- is this intentional, or an omission?
– Darragh Enright
Nov 23 '18 at 11:23
@DarraghEnright not intentional, i've changed my code to a better format and updated my question :)
– Projet Sin
Nov 23 '18 at 11:29
I understand now. This is not something you can configure or control directly usingDateTime
andDatePeriod
- this is a locale based question, andDateTime
does not honour locales. You have a few choices, includingIntlDateFormatter
if you have it installed, orstrftime()
. Here are some helpful answers
– Darragh Enright
Nov 23 '18 at 11:43
I tried this : echo strftime("%d %B", $dateDebutCalendrier->getTimestamp()); but this is still in English
– Projet Sin
Nov 23 '18 at 13:05
@ProjetSin - Check out the dup question, which bears an uncanny resemblance to yours, asked one week earlier. Are you and that author (kalvn) associated in some way? This seems like another case of StackOverflow déjà-vu... Can you shed some light on this phenomenon? Thanks.
– Matt Johnson
Nov 26 '18 at 22:25
I'm not sure what you mean by "the good time zone"? Can you edit your question to clarify 1. what result you are getting and 2. what result you expect? You're not passing a
DateTimeZone
to $lastDayThisMonth
- is this intentional, or an omission?– Darragh Enright
Nov 23 '18 at 11:23
I'm not sure what you mean by "the good time zone"? Can you edit your question to clarify 1. what result you are getting and 2. what result you expect? You're not passing a
DateTimeZone
to $lastDayThisMonth
- is this intentional, or an omission?– Darragh Enright
Nov 23 '18 at 11:23
@DarraghEnright not intentional, i've changed my code to a better format and updated my question :)
– Projet Sin
Nov 23 '18 at 11:29
@DarraghEnright not intentional, i've changed my code to a better format and updated my question :)
– Projet Sin
Nov 23 '18 at 11:29
I understand now. This is not something you can configure or control directly using
DateTime
and DatePeriod
- this is a locale based question, and DateTime
does not honour locales. You have a few choices, including IntlDateFormatter
if you have it installed, or strftime()
. Here are some helpful answers– Darragh Enright
Nov 23 '18 at 11:43
I understand now. This is not something you can configure or control directly using
DateTime
and DatePeriod
- this is a locale based question, and DateTime
does not honour locales. You have a few choices, including IntlDateFormatter
if you have it installed, or strftime()
. Here are some helpful answers– Darragh Enright
Nov 23 '18 at 11:43
I tried this : echo strftime("%d %B", $dateDebutCalendrier->getTimestamp()); but this is still in English
– Projet Sin
Nov 23 '18 at 13:05
I tried this : echo strftime("%d %B", $dateDebutCalendrier->getTimestamp()); but this is still in English
– Projet Sin
Nov 23 '18 at 13:05
@ProjetSin - Check out the dup question, which bears an uncanny resemblance to yours, asked one week earlier. Are you and that author (kalvn) associated in some way? This seems like another case of StackOverflow déjà-vu... Can you shed some light on this phenomenon? Thanks.
– Matt Johnson
Nov 26 '18 at 22:25
@ProjetSin - Check out the dup question, which bears an uncanny resemblance to yours, asked one week earlier. Are you and that author (kalvn) associated in some way? This seems like another case of StackOverflow déjà-vu... Can you shed some light on this phenomenon? Thanks.
– Matt Johnson
Nov 26 '18 at 22:25
|
show 1 more comment
1 Answer
1
active
oldest
votes
Thanks to comment, this is the solution :
setlocale(LC_TIME, 'fr_FR','fra');
echo(strftime("%B", $dateDebutCalendrier->getTimestamp());
Small edit : i needed also to add (3*3600) to the time stamp to get the right first day of the period.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to comment, this is the solution :
setlocale(LC_TIME, 'fr_FR','fra');
echo(strftime("%B", $dateDebutCalendrier->getTimestamp());
Small edit : i needed also to add (3*3600) to the time stamp to get the right first day of the period.
add a comment |
Thanks to comment, this is the solution :
setlocale(LC_TIME, 'fr_FR','fra');
echo(strftime("%B", $dateDebutCalendrier->getTimestamp());
Small edit : i needed also to add (3*3600) to the time stamp to get the right first day of the period.
add a comment |
Thanks to comment, this is the solution :
setlocale(LC_TIME, 'fr_FR','fra');
echo(strftime("%B", $dateDebutCalendrier->getTimestamp());
Small edit : i needed also to add (3*3600) to the time stamp to get the right first day of the period.
Thanks to comment, this is the solution :
setlocale(LC_TIME, 'fr_FR','fra');
echo(strftime("%B", $dateDebutCalendrier->getTimestamp());
Small edit : i needed also to add (3*3600) to the time stamp to get the right first day of the period.
edited Nov 23 '18 at 14:50
answered Nov 23 '18 at 13:09
Projet SinProjet Sin
757
757
add a comment |
add a comment |
I'm not sure what you mean by "the good time zone"? Can you edit your question to clarify 1. what result you are getting and 2. what result you expect? You're not passing a
DateTimeZone
to$lastDayThisMonth
- is this intentional, or an omission?– Darragh Enright
Nov 23 '18 at 11:23
@DarraghEnright not intentional, i've changed my code to a better format and updated my question :)
– Projet Sin
Nov 23 '18 at 11:29
I understand now. This is not something you can configure or control directly using
DateTime
andDatePeriod
- this is a locale based question, andDateTime
does not honour locales. You have a few choices, includingIntlDateFormatter
if you have it installed, orstrftime()
. Here are some helpful answers– Darragh Enright
Nov 23 '18 at 11:43
I tried this : echo strftime("%d %B", $dateDebutCalendrier->getTimestamp()); but this is still in English
– Projet Sin
Nov 23 '18 at 13:05
@ProjetSin - Check out the dup question, which bears an uncanny resemblance to yours, asked one week earlier. Are you and that author (kalvn) associated in some way? This seems like another case of StackOverflow déjà-vu... Can you shed some light on this phenomenon? Thanks.
– Matt Johnson
Nov 26 '18 at 22:25