Re: Converting a "timestamp"
| From: | Narcis Garcia | Date: | Sun, 19 Feb 2017 11:23:34 +0000 |
| Subject: | Re: Converting a "timestamp" | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325979@lists.php.net to get a copy of this message | ||
In SQL language you still can take Aziz example to perform this:
UPDATE MyTable SET MyDate = CONCAT(SUBSTRING(MyDate, 1, 4), '-',
SUBSTRING(MyDate, 6, 2), '-',...);
The result will be complete conversion of original rare format to your
customized format.
El 19/02/17 a les 04:34, Jennifer ha escrit:
>> On Feb 18, 2017, at 12:47 PM, Don Wieland <donw@pointmade.net> wrote:
>>
>> function convert_stamp($stamp) {
>> $ta = explode(‘|’, $stamp);
>> return $ta[‘0’].’-‘.$ta[‘1’].’-‘.$ta[‘2’].’ @
>> ‘.$ta[‘3’].’:‘.$ta[‘4’].’:‘.$ta[‘5’];
>> }
>
> Thanks for the function, Don. That did end up coming in handy, but my main question was about
> getting the data out of MySQL and then back in, which I couldn’t really solve. I could get the
> data into an array and massage it, but I couldn’t figure out how to get it back in. So I ended up
> just exporting the data from the table, manipulating the file in PHP, then importing back into the
> table. A round about way, but at least it’s done.
>
> Jenni
>