Converting a "timestamp"
| From: | Jennifer | Date: | Sat, 18 Feb 2017 20:26:02 +0000 |
| Subject: | Converting a "timestamp" | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-325970@lists.php.net to get a copy of this message | ||
I have a "timestamp" written to a text field in MySQL that I need to convert in every
record. Currently it is formatted like 2017|02|16|04|58|42
and I want to convert it to this format 2017-02-16 @ 04:58:42
What’s the best way to do this? Do I need to read each record, convert it in PHP, and then
insert it back into the table? Or is there a shorter way of doing this that doesn’t require both
reading and writing each record?
Also, if it’s easier, is there a way to do this directly in MySQL?
I’m not really asking for code at this point, as I’m just trying to figure out how to get
started.
Thank you,
Jenni