⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

The date format used in Europe and elsewhere



pvalen

pvalen
  • profile picture
  • Member

Posted 31 May 2013 - 12:02 PM

Please add the new version to a file grocery_crud.php to function _load_date_format()

 

case 'eu-date':
    $this->php_date_format = "$php_day.$php_month.$php_year";
    $this->js_date_format  = "$js_day.$js_month.$js_year";
    $this->ui_date_format  = "$ui_day.$ui_month.$ui_year";
break;

 

the data format (1.1.2013 13:25) used in Europe and elsewhere.

 

Please also addition function to enter text information to the item on the form. Using callback_ is not applicable for example to insert file, date etc..

callback_edit_field
http://www.grocerycrud.com/examples/callback_edit_field_example
callback_add_field
http://www.grocerycrud.com/examples/callback_add_field_example


davidoster

davidoster
  • profile picture
  • Member

Posted 01 June 2013 - 07:21 AM

Under application/config there is this line,

 

// There are only three choices: "uk-date" (dd/mm/yyyy), "us-date" (mm/dd/yyyy) or "sql-date" (yyyy-mm-dd) 
$config['grocery_crud_date_format'] = 'uk-date';

How the proposed 'eu date' you ask to add is different from this 'uk_date'?

 

Now for the callbacks for add and edit. Because of the special nature of the callback functions in PHP what you ask is not possible.

Read here for your information.


pvalen

pvalen
  • profile picture
  • Member

Posted 06 June 2013 - 08:43 AM

The date format is in Central Europe (dd.mm.yyyy) other than in England (dd/mm/yyyy)

 

I want you to do directly in the function _load_date_format() add this code. So then the function looks like:

 

protected function _load_date_format()
 {
  list($php_day, $php_month, $php_year) = array('d','m','Y');
  list($js_day, $js_month, $js_year) = array('dd','mm','yy');
  list($ui_day, $ui_month, $ui_year) = array('dd','mm','yyyy');
//@todo ui_day, ui_month, ui_year has to be lang strings
  
  $date_format = $this->config->date_format;
  switch ($date_format) {
   case 'uk-date':
    $this->php_date_format   = "$php_day/$php_month/$php_year";
    $this->js_date_format  = "$js_day/$js_month/$js_year";
    $this->ui_date_format  = "$ui_day/$ui_month/$ui_year";
   break;
   
   case 'us-date':
    $this->php_date_format   = "$php_month/$php_day/$php_year";
    $this->js_date_format  = "$js_month/$js_day/$js_year";
    $this->ui_date_format  = "$ui_month/$ui_day/$ui_year";
   break;
   
   case 'eu-date':
    $this->php_date_format   = "$php_day.$php_month.$php_year";
    $this->js_date_format  = "$js_day.$js_month.$js_year";
    $this->ui_date_format  = "$ui_day.$ui_month.$ui_year";
   break;
   
   case 'sql-date':
   default:
    $this->php_date_format   = "$php_year-$php_month-$php_day";
    $this->js_date_format  = "$js_year-$js_month-$js_day";
    $this->ui_date_format  = "$ui_year-$ui_month-$ui_day";
   break;
  }
 }

 

I have added it myself and it works.


pvalen

pvalen
  • profile picture
  • Member

Posted 06 June 2013 - 09:19 AM

I do not want to do it with the callbacks. I would like you to do a new function, so I could add some text before or after <input ...> etc.

 

Using the callbacks is difficult and can not be used for inserting the date, file, etc.


davidoster

davidoster
  • profile picture
  • Member

Posted 06 June 2013 - 13:12 PM

Oh! Ok!

And I want you to post an issue here!

You welcome!