![]() |
date('Y-m-d') don't work !!! [resolved] - 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('Y-m-d') don't work !!! [resolved] (/showthread.php?tid=41301) |
date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]krislec[/eluser] Hi guys. I don't understand why ma date is wrong: I use for my varaible: $date = date('Y-m-d',strtotime($this->input->post('my_date') echo $date gives me: Y-d-m !!! but I'm waiting Y-m-d.... A french Guy. Thanks. date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]Sudz[/eluser] What is the value of $this->input->post(‘my_date’); is it posted from form? Post your code. date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]lontong balap[/eluser] you should check your 'my_date' format date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]krislec[/eluser] the view: Code: ... the controller: Code: ... I need to put date('m/d/Y') to have a real date with this format d/m/Y (for the screen)...??? I have made little test function but i don't how I can make it in use in the set->rules line. Code: /* Date au format 0000-00-00 */ Thanks for helping me. date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]johnpeace[/eluser] Doesn't the format string have to be in double quotes? date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]danmontgomery[/eluser] [quote author="johnpeace" date="1304526900"]Doesn't the format string have to be in double quotes?[/quote] No. I'm guessing what's happening here is that you're inputting the date as dd/mm/yyyy, and strtotime() thinks the date is in "american" mm/dd/yyyy format, as it's wont to do. see: http://www.php.net/manual/en/function.strtotime.php#100144 I would force - rather than /, replace the characters before converting format, or use something like jquery datepicker date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]krislec[/eluser] Ok. I'm working on it... THKS. Ok great ! I undrestand : Quote:Forward slash (/) signifies American M/D/Y formatting, a dash (-) signifies European D-M-Y date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]krislec[/eluser] I'm going to try with jquery datepicker, but... How can I make this works (for example and if I need to do this) ? ... $this->form_validation->set_rules('date_age','Date de naissance','trim|test_my_date|required|xss_clean'); Where I have to put my code (function test_my_date() in ? A new helper that I have to include in /application/helpers ? date('Y-m-d') don't work !!! [resolved] - El Forum - 05-04-2011 [eluser]krislec[/eluser] Ok. That's done. It works fine with "-" rather than "/", with or whithout date picker. Thanks. K. ps => Resolved ! |