![]() |
date woes - 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: date woes (/showthread.php?tid=24135) |
date woes - El Forum - 11-01-2009 [eluser]tim1965[/eluser] Firstly apologies for posting this issue here. Its not a CI problem but it is driving me nuts so i thought i would take a scatter gun approach and hit all the good forums. This is such a simple thing that i cant believe i havent found an answer to it after 3 hrs. Ok onto the problem. I have a date field in MySql type DATE and default set to NULL. If a date is not entered the default value for NULL that is being applied is 0000-00-00. All well and good. However when i try and display the date using Code: echo strftime("%d-%m-%y", strtotime($start_date) Quote:01-01-70. Mt problem is that i just want a blank field. I am sure that this is a problem that lots of people have run into before, but i cannot find anything about how to handle it. Any help much appreciated. date woes - El Forum - 11-01-2009 [eluser]umefarooq[/eluser] for you problem if you want to format date dd,mm,yy you just use mysql date_format() function in query it very handy and fast to convert the date in you desired format or check CI documentation for date helper CI doc http://ellislab.com/codeigniter/user-guide/helpers/date_helper.html mysql http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format or http://www.w3schools.com/SQL/func_date_format.asp date woes - El Forum - 11-01-2009 [eluser]tim1965[/eluser] umefarooq Many thanks for ths response. I was trying to be too clever in what i was trying to do, hence i was getting confused. I could not use the CI helper stuff as this is a legacy system and stores dates as dates. However as always go with the simplest solution which was an explode of the string. Many thanks again. |