Получите формат даты как “Y-m-d H:i:s” с php даты

У меня есть список их в , Бесконечный цикл на E2 - видит просто тех обозначенных как "Переполнение стека" в заголовке.

я думаю самое короткое, там

[dx]dx

в dc. Может быть более короткое решение в Ложь .

РЕДАКТИРОВАНИЕ: По-видимому, это не работает... По крайней мере, на GNU dc. Возможно, это было на версии BSD.

8
задан ateeq24 26 April 2018 в 05:33
поделиться

2 ответа

As far as I'm aware, there's no guaranteed way of working backwards. The best way might be to try to match regular expressions against expected well-known formats (e.g. \d{2,4}[-/]\d{2}[-/]\d{2} for "Y-m-d") but I can't think of an easy way to do the matching without using regular expressions. You would also have to check that the parsed format makes sense, and you can't do much about ambiguous dates like 2nd of March 2009, which could be represented as 09/03/02, 2009-03-02, 02/03/09, 03/02/09, or even 09/02/03.

5
ответ дан 5 December 2019 в 07:11
поделиться

You can convert string date to timestamp with strtotime and do with the timestamp what ever you want. ;)

<?php
$date = "2009-10-16 21:30:45";
$ts   = strtotime($date);
echo date('Y-m-d', $ts);
?>
9
ответ дан 5 December 2019 в 07:11
поделиться
Другие вопросы по тегам:

Похожие вопросы: