Questions tagged [intldateformatter]

16 questions
5
votes
2 answers

IntlDateFormatter returning the wrong year

If you run the following code
TMH
  • 6,096
  • 7
  • 51
  • 88
2
votes
1 answer

Php IntlDateFormatter class does not show unix timestamp

I'm trying to get the unix timestamp with IntlDateFormatter. I've tried this $formatter = new IntlDateFormatter( 'fr_FR', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Europe/Paris', …
dvlpr.963
  • 384
  • 1
  • 4
  • 15
2
votes
1 answer

How do I force PHP's IntlDateFormatter to ignore the year ONLY from the output?

Example code: $a = new IntlDateFormatter('en-US', IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Europe/London', IntlDateFormatter::GREGORIAN); var_dump($a->format(strtotime('2021-09-17 15:00'))); $a = new IntlDateFormatter('sv-SE',…
user16508174
  • 281
  • 1
  • 6
1
vote
0 answers

Why does \IntlDateFormatter's format differ from \DateTime->format() on given timezone?

I am trying to fix a timezone issue in a PHP 8.2 web application. Any date before 1940-02-25 has a one-day difference when comparing the production server (Debian 12) to my local development machine (Fedora 38). Both machines have PHP 8.2, the…
1
vote
0 answers

How to format a period of time with IntlDateFormatter in PHP

I would like to output a formatted period of time for different locales, e.g.: de_DE: 25. - 28. August 2022 es_ES: 25-28 de agosto de 2022 So far I have to 'construct' this output. Example: $locales = array( 'de_DE', 'en_GB', 'fr_FR', …
schasiepen
  • 11
  • 1
1
vote
2 answers

PHP IntlDateFormatter - remove "day" from the date format

I want to remove "day" from the pattern to display the correct INTL date in format "F, Y". How to correctly do it without str_replace-ing "d" character with dots (and other symbols) in the $tempPattern variable? I can't use $formatter->setPattern(),…
Nubian
  • 153
  • 6
1
vote
1 answer

IntlDateFormatter::format adds a year to a date

This is weird, perhaps even a bug... The timestamp for Dec 26, 2021 00:00:00 GMT is 1640476800: php > var_dump(gmdate("Y-m-d H:i:s", 1640476800)); string(19) "2021-12-26 00:00:00" But when I use IntlDateFormatter::format(), the year changes to 2022…
drmad
  • 530
  • 5
  • 16
1
vote
1 answer

IntlDateFormatter php japanese year convertion return false for 2019

I want to convert 令和元年8月 = 2019年8月 Ref https://www.conservapedia.com/Japanese_dates Here I get these For this I tried code like below here "平成31年8月" returning 2019 but according to ref it should 令和元年8月 Please suggest me is there any solution so I…
Lemon Kazi
  • 3,308
  • 2
  • 37
  • 67
0
votes
0 answers

Problem with using IntlDateFormatter()->format()

I have a problem using the IntlDateFormatter class. The following code gives different results if it is executed by apache or cli
0
votes
1 answer

php IntlDateFormatter get day from array

i am trying to get holidays from an array. the code outputs : Neujahr: So., 1. Januar 2022 01:0101 Allerheiligen: Mi., 1. November 2023 01:0101 but should output: Neujahr: So., 1. Januar 2023 01:0101 (2023 not 2022 !! ) This only happens with date…
Sepp Hofer
  • 217
  • 2
  • 12
0
votes
1 answer

php - IntlDateFormatter() wrong/weird timestamp in comparison to DateTime() output

I noticed that IntlDateFormatter() function returns wrong timestamp in comparison to same type of output from DateTime() function. PHP: $formatter = new IntlDateFormatter( 'en_GB', IntlDateFormatter::SHORT, …
X9DESIGN
  • 774
  • 1
  • 10
  • 23
0
votes
1 answer

Calculate chinese new year date

I want to find out the Chinese New Year date for a specific year using PHP. For the year 2022 I expect February 1st, 2022.
jspit
  • 7,276
  • 1
  • 9
  • 17
0
votes
0 answers

Where do i find information regarding the Pattern need to get the week-day using IntlDateFormatter in PHP?

I stumbled upon this solution for getting the week-day on my language but I am still trying to find information regarding the pattern needed to do it, as you can see the pattern is "EEEE" if i were to use date() it would be "l". When i tried with…
SHJordan
  • 1
  • 1
  • 1
0
votes
0 answers

IntlDateFormatter. Timezone acronym lost when locale is changed

im trying to do something like this (https://www.php.net/manual/en/intldateformatter.getlocale.php):
0
votes
1 answer

Why does IntlDateFormatter not return "false" even with obviously made-up locale/language strings?

Source: https://www.php.net/manual/en/intldateformatter.create.php Quote: Return Values ¶ The created IntlDateFormatter or FALSE in case of failure. Code: $fmt = new IntlDateFormatter( "en_US" ,IntlDateFormatter::FULL, IntlDateFormatter::FULL, …
user379490
  • 159
  • 5
1
2