D
D
Darth Vader2015-12-08 21:40:26
PHP
Darth Vader, 2015-12-08 21:40:26

How to manipulate date in php?

I can’t convert the date of the format 2016-02-29T21:53:00to this format: год, месяц, день, часы, минуты, i.e. 2016,02,29,21,53

without -,: and the letter T

I tried as in this article but nothing happened phpclub.ru/detail/article/date_stuff

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
Pavel K, 2015-12-08
@blackdarthvader

You initially have a string in a non-normal format, so you must first convert it to the DateTime format,
and then further convert it:

$date = DateTime::createFromFormat('Y-m-d\TG:i:s', '2016-02-29T21:53:00');
echo $date->format('Y,m,d,G,i,s');

Although, maybe this is an overkill and you can stupidly replace "-" ":" "T" with commas (it smells like a crutch),
it all depends on the task and needs.

I
Ilya Korablev, 2015-12-08
@swipeshot

Use the normal PHP documentation.

O
Oleg Spiridonov, 2015-12-08
@spd78

But if you directly convert what is already there - preg_replace will help.

P
prishelec, 2015-12-08
@prishelec

To help you php.net/manual/en/function.strtotime.php.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question