From dd/mm/YYYY - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: From dd/mm/YYYY (/showthread.php?tid=11302) |
From dd/mm/YYYY - El Forum - 09-03-2008 [eluser]Unknown[/eluser] i have string '25/02/2008' how to make 2008/02/25 From dd/mm/YYYY - El Forum - 09-03-2008 [eluser]xwero[/eluser] the easiest way is Code: list($day,$month,$year) = explode('/','25/02/2008'); From dd/mm/YYYY - El Forum - 09-03-2008 [eluser]Bruno França[/eluser] Or... Code: function br2mysql($data) { From dd/mm/YYYY - El Forum - 09-03-2008 [eluser]xwero[/eluser] Bruno has the easiest way but i suggest you add some form of date validation before you change the format of the string. From dd/mm/YYYY - El Forum - 09-03-2008 [eluser]phpoet[/eluser] I usually use strtotime() in combination with date() for my date manipulation but this particular starting date format doesn't work with strotime. So this has been a really helpful thread. Thanks! |