There is a date in this format July 25, 2016, you need to get 2016-07-25 I do so
echo date("Ymd", strtotime($dbtArr[1]));
I get 1970-01-01 03:00:00. What to do? I hope there is a way without explode and enumeration of synonyms for months.
Use this crutch:
$dbtArr[1] = '25 июль 2016'; $dbtArr[1] = str_replace(array('январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'), array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'), $dbtArr[1]); echo date("Ymd", strtotime($dbtArr[1]));
Answer without explode and search for synonyms for months:
<?php setlocale(LC_ALL, 'ru_RU', 'ru_RU.UTF-8', 'ru', 'russian'); echo strftime("%B %d, %Y", time());
21st century: there is localization, and the correct analysis of the date and time.
Source: https://ru.stackoverflow.com/questions/548189/
All Articles
25 июль 2016
as a string? - Visman