date('Y-m-d') don't work !!! [resolved] |
[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.
[eluser]Sudz[/eluser]
What is the value of $this->input->post(‘my_date’); is it posted from form? Post your code.
[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.
[eluser]johnpeace[/eluser]
Doesn't the format string have to be in double quotes?
[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.st...php#100144 I would force - rather than /, replace the characters before converting format, or use something like jquery datepicker
[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
[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 ?
[eluser]krislec[/eluser]
Ok. That's done. It works fine with "-" rather than "/", with or whithout date picker. Thanks. K. ps => Resolved ! |
Welcome Guest, Not a member yet? Register Sign In |