Welcome Guest, Not a member yet? Register   Sign In
Date conversion in codeigniter
#3

[eluser]mddd[/eluser]
Mysql is a bit flexible on how you specify the date, but the important thing is that the order must be year-month-day. If your date is already a string, you could use:
Code:
$mydate = '02/05/2010';
$this->db->set('mydate', join('-',array_reverse(explode('/',$mydate))));
In other words, make the date into an array, reverse its order, out it back together again. It doesn't really matter what you put in between the parts (a - or a /).

For getting the date FROM the database, use Mysql's date_format function. It works just like date() in php. But why process it in php if you can get it the right way from Mysql in the first place. See date_format in the Mysql manual .


Messages In This Thread
Date conversion in codeigniter - by El Forum - 06-06-2010, 08:33 PM
Date conversion in codeigniter - by El Forum - 06-07-2010, 12:29 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 02:00 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 05:37 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 05:45 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 06:20 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 06:27 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 06:36 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 06:42 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 08:43 AM
Date conversion in codeigniter - by El Forum - 06-07-2010, 09:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB