PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 10, 2022

[FIXED] i18nFormat with CakePHP 3 - Why does YYYY produce a different year than yyyy?

 March 10, 2022     cakephp-3.0, internationalization, php, time     No comments   

Issue

I'm working in CakePHP 3 and I noticed today that this:

    $time = new Time('now');

    $this->set('time', $time->i18nFormat('YYYY')); // echoes '2015'

Echoes 2015. Changing it to lowercase 'yyyy', instead, produces 2014.

    $time = new Time('now');

    $this->set('time', $time->i18nFormat('yyyy')); // echoes '2014'

Why is this the case?


Solution

Uppercase Y is the year that the week of the timestamp is in "Week of Year" based calendars. This week now, is in 2015 so it returns 2015. Lowercase y is the current year for the timestamp, which for now is 2014.

Date Field Symbol Table



Answered By - AbraCadaver
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing