I seem to be making a real mess of dates in combination with I18N.

Dates are stored in the DB in the MySQL date format (YYYY-MM-DD).

When I retrieve my date from the database using my models getDate (for  
instance), I use date_format to format the date according to the users  
culture, which in my case returns the date formatted as DD/MM/YYYY

The input_date_tag in my template looks like this :

<?php echo input_date_tag('startdate', format_date($startdate),  
array('culture' => $culture, 'rich' =>  true,  'calendar_options' =>  
'firstDay: 1, range: Array(2007,'.(date('Y')+3).')')); ?>

And in my action I'm using this code to format the date BACK to the  
format compatible with the MySQL date format (as per this snippet : 
http://www.symfony-project.org/snippets/snippet/44)

list($d, $m, $y) = sfI18N::getDateForCulture($this- 
 >getRequestParameter('startdate'), 'en_GB');
$this->startdate = "$y-$m-$d";
$task->setStartDate($this->startdate);

However, this date is never getting into the database.

I can see this is my log...

May 08 10:56:07 symfony [info] {sfRequest} request parameters array  
(  'module' => 'my_module',  'action' => 'showTaskDetails',   
'startdate' => '08',  '05' => '2008',  'enddate' => '15',   
'content_object_id' => 'tsn11_l2it1',  'learner_id' => '4',  'subject'  
=> '1',  'anaction' => 'update',)
May 08 10:56:08 symfony [err] {sfException} Unable to parse date/time  
value for [startdate] from input: '--'

It seems the calendar widget is sending the date back to the action  
incorrectly - 'startdate' => '08',  '05' => '2008', - shouldn't  
startdate be an array?

Am I going wrong somewhere, or is the date helper going wrong?





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to