How to insert : and - into timestamp string from IoT device?
| From: | Bo Berglund | Date: | Fri, 16 Dec 2022 08:23:26 +0000 |
| Subject: | How to insert : and - into timestamp string from IoT device? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-328104@lists.php.net to get a copy of this message | ||
I have an Arduino IoT device which reads data from an electricity meter and
posts to a website database through a web call to a php script on my webserver.
THis works fine and the timestamp gets into the database as expected.
However it is hard to read so I want to add separators before storing onto the
database.
The timestamp retrieved from the meter looks like this example:
221216085802
It is sent by adding parameter ×tamp=221216085802 to a get call to the php
script.
In php on the webserver before I store it into the database I want to convert it
to a more readable format so it looks like this:
22-12-16 08:58:02
How can I do this in php code?
I.e insert two - one space and two : into the string at given positions
--
Bo Berglund
Developer in Sweden