A
A
AliaksandrShuhov2019-09-06 23:05:26
PHP
AliaksandrShuhov, 2019-09-06 23:05:26

How to convert a string using regular expressions (PHP)?

There are inputs like:

$date_and_time = array (
 [0] => '06.08.2019 12:09:43',
 [1] => '06.08.2019 09:45:19',
 [2] => '29.07.2019 14:13:31'
);

I don't want to reinvent the wheel.
You need to transform this with regular expressions and get something like this:
$date_and_time = array (
 [0] => array (
  'date' => '29.07.2019',
  'time' => ''14:13:31,
  'unix_time' => 1564409611
),
 [1] => array (
  'date' => '06.08.2019',
  'time' => '09:45:19',
  'unix_time' => 1559987119
),
 [2] => array (
  'date' => '29.07.2019',
  'time' => '14:13:31',
  'unix_time' => 1564409611
),;

Thanks to.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
green_goo, 2019-09-06
@AliaksandrShuhov

Regular expressions are not needed here
https://www.php.net/manual/ru/datetime.createfromf...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question