Change the language for date in php

Viewed 46025

I have this MySQL query, which returns two dates (which are both formatted as a-m-Y). Now I want to translate this date into my own language (Danish). How can I do that. I have tried both the setlocale() and strftime() functions, but it won't work. I know it's a very basic question, but i really need help :) Thanks a lot!

6 Answers

This Will Surely works for you if you want norwegian date and month format

$date = '2016-11-16 05:35:14';
setlocale(LC_TIME, array('nb_NO.UTF-8','nb_NO@norw','nb_NO','norwegian'));
echo strftime("%e %b %Y",strtotime($date));

if you want to get other language locale ids like nb_NO then refer this site International Components for Unicode (ICU) Data

Related