alter_date function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: alter_date function (/showthread.php?tid=7638) |
alter_date function - El Forum - 04-17-2008 [eluser]xwero[/eluser] One of my problems with the validation library is that allows developers to alter $_POST values. That is why i'm working on a method that puts the $_POST alterations in the library where it belongs to namely the input library. One of the functions i currently needed was altering a date and i wanted to share it with you because i'm going to release the input method with an upgrade of the validate library. Code: function alter_date($value,$from,$to,$locale=NULL) For English dates there is strtotime but if the date format isn't right or if there are non English words in it the function isn't useful anymore. Examples Code: $date1 = '1-1-2008'; A modification is that you replace the date function with the strftime function. But i made the function with database insertion in mind. |