Answer the question
In order to leave comments, you need to log in
How to convert Russian time to numeric date in PHP?
I need to fit the reading date to my database.
The date and time to be processed is June 27 17:51:58 .
And then convert to the following format: 2014-06-27 17:51:58 .
I should warn you that I'm on Windows 7 SP1 English, in the regional settings is Unicode - Russian.
I tried the following code but it gives an error: A non well formed numeric value encountered
$myTimeString = '27 Июня 17:51:58';
setlocale(LC_TIME, 'ru_RU', 'Russian_Russia', 'Russian');
$formatted_time = strftime('%d %B %H:%M:%S', $myTimeString);
echo date('Y-m-d H:i:s', $formatted_time);
Answer the question
In order to leave comments, you need to log in
Something like this:
$myTimeString = '27 Июня 17:51:58';
$month1 = array('Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек');
$month2 = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря');
$time = date("Y-m-d H:i:s", strtotime(str_replace($month2, $month1, mb_strtolower($myTimeString, 'utf-8'))));
As a clumsy, but working option, you can write a helper function that will change the Russian names of the months to English, the result of which is already fed to strftime ()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question