Skip to content

Change locale for Calendar datepicker

Below is a snippet to change the datepicker locale

<?php
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
$dg->set_locale('es');      
$dg->enable_edit('FORM');

$dg -> set_col_property("requiredDate",
                            array("formatter"=>"date",
                                  "formatoptions"=>array("srcformat"=>"Y-m-d","newformat"=>"m/d/Y"),
                                  "editoptions"=>array(
                                        "dataInit"=>"function(el) {
                                          $(el).datepicker( $.datepicker.regional[ 'es' ] )
                                        }")));

$dg -> display();
?>

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>

1. The main change is to add the following in dataInit

$(el).datepicker( $.datepicker.regional[ 'es' ] );

2. Include script link to jQueryUI in the bottom of the page


Feedback and Knowledge Base