Sunday, January 16, 2022

[FIXED] how to change longtext a:3:{s:4:"year";s:4:"2018";s:5:"month";s:2:"07";s:3:"day";s:2:"05";} to date 2018-07-05

Issue

Hi I am using cakephp3 and saving data in key-value pair but not able to convert this

a:3:{s:4:"year";s:4:"2018";s:5:"month";s:2:"07";s:3:"day";s:2:"05";}

and result i want in this form

date 2018-07-05

in php


Solution

Give a try with below

$date = unserialize('a:3:s:4:"year";s:4:"2018";s:5:"month";s:2:"07";s:3:"day";s:2:"05";}');

echo 'date '.$date['year'].'-'.$date['month'].'-'.$date['day']; //date 2018-07-05


Answered By - shubhangee

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.