2

I'm working on a CakePHP 3 application and the problem that I'm having right now is that I'm using the PHP date function to display dates in format like "date month year" (for example: 12 Sept 2018) like so:

date('d M Y', strtotime(my_mysql_datetime));

but the problem is that it works when the website is in english, but when I change the website language to french for example, the datetime format also changes which results in strtotime returning false.

How can I prevent the datetime that I get from my database to change when I switch the website language?

user765368
  • 19,590
  • 27
  • 96
  • 167
  • Where do you get `my_mysql_datetime` from? If its from an `Entity`, `my_mysql_datetime` should be either a `Cake\I18n\Time` or `Cake\I18n\Date` object which extends PHP `DateTime` where you can call ->format() like so `my_mysql_datetime->format('d M y')` – Vindur Nov 12 '18 at 08:39

0 Answers0