datetime Archives | phpGrid - PHP Datagrid Create PHP grids in minutes, not hours. Fri, 06 Dec 2024 04:16:19 +0000 en-US hourly 1 CodeProjecthttps://wordpress.org/?v=7.0.3 129966043 Complete Date Format Demo (Updated) https://phpgrid.com/example/complete-date-format-demo/ Fri, 23 Nov 2018 15:57:41 +0000 http://phpgrid.com/?p=8560

The example demonstrates date column formatting using functions set_col_date, set_col_datetime, set_col_property(…formatter”=>”date”,…). If you have trouble with date format, most likely you will find answer here. One can “fine tune” the jQuery datepicker properties like year range and min and max date. The jQuery UI Datepicker is a highly configurable plugin that one can customize the […]

The post Complete Date Format Demo (Updated) appeared first on phpGrid - PHP Datagrid.

]]>

The example demonstrates date column formatting using functions set_col_date, set_col_datetime, set_col_property(…formatter”=>”date”,…). If you have trouble with date format, most likely you will find answer here.

One can “fine tune” the jQuery datepicker properties like year range and min and max date. The jQuery UI Datepicker is a highly configurable plugin that one can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use phpCtrl\C_DataGrid;
require_once("/file/path/to/conf.php");  

$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");

// Method 1: change date display and datepicker display (used for edit) to Spanish date
$dg -> set_col_date("orderDate", "Y-m-d", "m/d/Y", "m/d/yy");

// Method 2: change date display and datepicker display (used for edit) to Spanish date
$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({
                                                changeMonth: true,
                                                changeYear: true,
                                                dateFormat: 'm/d/yy',
                                                yearRange: '-50:+50', // set range of selectable years back and future 50 yrs
                                                minDate: '+100d'      // minimum selectable date is 100 days into future
                                            })
                                        }"
)));

// Method 3: Display using jQuery Datetimepicker extension replacing the built-in datepicker plus option time picker
$dg -> set_col_datetime("contractDateTime", "Y-m-d H:i", "m/d/Y H:i", "m/d/Y H:i");

// Display time only. No date. It cannot be edited, so we also made it hidden on the edit form.
$dg -> set_col_property("shippedDate",
            array("formatter"=>"date",
                "formatoptions"=>array("srcformat"=>"ISO8601Short","newformat"=>"g:i A"),
                'editable'=>false,'hidedlg'=>true));


$dg->enable_edit();
$dg -> display();

See Live demo!

Note
Starting version 7.2.8, for MySQL, the pickers for the Date, Time and DateTime are automatically used respectively based on the datbase field type. This is for MySQL database only. Users no longer need to specify the date type with set_col_format.

Date Picker (MySQL Date)

Datetime Picker (MySQL Datetime)

Time Picker (MySQL Time)

See Live demo!

The post Complete Date Format Demo (Updated) appeared first on phpGrid - PHP Datagrid.

]]>
8560
set_col_datetime() https://phpgrid.com/documentation/set_col_datetime/ Sat, 22 Sep 2018 16:05:28 +0000 http://phpgrid.com/?p=9453 * Currently only supported in the commercial licenses  The function is almost identical to set_col_date() except it also has a time picker. Parameters: $col_name: column name $srcformat: source date format, eg. “Y-m-d” $newformat: new date form to be displayed, eg. “m/d/Y” $datepicker_format: datepicker format, eg. “m/d/yy” Description:  Helper function to format the date using PHP […]

The post set_col_datetime() appeared first on phpGrid - PHP Datagrid.

]]>
* Currently only supported in the commercial licenses 

The function is almost identical to set_col_date() except it also has a time picker.

  • Parameters:
    • $col_name: column name
    • $srcformat: source date format, eg. “Y-m-d”
    • $newformat: new date form to be displayed, eg. “m/d/Y”
    • $datepicker_format: datepicker format, eg. “m/d/yy”
  • Description:
    •  Helper function to format the date using PHP date format options (http://php.net/manual/en/function.date.php). MySql always stores the date in either ‘YYYY-MM-DD’ or ‘YY-MM-DD’ format. However, we can still change the front-end date display format while conforming to its date standards.
  • Remark:
    • In most cases, you don’t need to call this method because phpGrid automatically formats the data with corresponding data type including the date.
    • Only use this method in order to display date format that is different from default date format.
    • To display time only, please use set_col_property instead.
  • Example:
1
2
// Display datetimepicker. Used when data is DATETIME type.
$dg -> set_col_datetime("myDateTime");

The post set_col_datetime() appeared first on phpGrid - PHP Datagrid.

]]>
9453
Timepicker Only Support https://phpgrid.com/example/timepicker-only-support/ Tue, 24 Apr 2018 19:01:56 +0000 http://phpgrid.com/?p=9427

phpGrid now has standalone time-picker support using set_col_time() method. Only the table fields that have TIME type are applicable. For non-TIME types, it will display the regular datetime picker. For database has no TIME type support, you can use Sql Datetime type and choose to show time only 12345// Display TIME. Requires column with SQL […]

The post Timepicker Only Support appeared first on phpGrid - PHP Datagrid.

]]>

phpGrid now has standalone time-picker support using set_col_time() method. Only the table fields that have TIME type are applicable. For non-TIME types, it will display the regular datetime picker. For database has no TIME type support, you can use Sql Datetime type and choose to show time only

1
2
3
4
5
// Display TIME. Requires column with SQL Time data type.
// For database has no TIME type support, you can use Sql Datetime type and choose to show time only
$dg -> set_col_time('logTime')->set_col_property("logTime",
            array("formatter"=>"date",
                "formatoptions"=>array("srcformat"=>"h:i A","newformat"=>"h:i A")));

In live demo, edit the “logTime” field to activate the timepicker.

See Live demo!

The post Timepicker Only Support appeared first on phpGrid - PHP Datagrid.

]]>
9427
Set Start Day of the Week in Datepicker https://phpgrid.com/example/set-start-day-week-monday-datepicker/ Tue, 24 Jan 2017 08:44:15 +0000 http://phpgrid.com/?p=9207

Sunday was named as the first day in Jewish and early Christian tradition. However, Sunday is not always the first day of the week. In fact, some years ago, the International Organization for Standardization specified Monday as the first day. North American continue to follow Sunday as the first day of the week, while Europeans […]

The post Set Start Day of the Week in Datepicker appeared first on phpGrid - PHP Datagrid.

]]>

Sunday was named as the first day in Jewish and early Christian tradition. However, Sunday is not always the first day of the week. In fact, some years ago, the International Organization for Standardization specified Monday as the first day. North American continue to follow Sunday as the first day of the week, while Europeans consider Monday the first day. Believe it or not, some countries have Saturday as the first day and some have no weeks (e.g. Africa)! Just see the start day of the week map below.

 

start-day-week

 

OK, enough of history. How do we actually go about changing the start day in our datepicker? Fear not, it is easier than you think. Just copy and paste the following event handling code in your phpGrid. It will change the default start day of the week from Sunday to Monday.

 
1
2
3
4
5
6
7
// change week start day to Monday
$weekStartDay = <<<DATEPICKWEEKSTARTDAY
function(){
    $('.hasDatepicker').datepicker('option', 'firstDay', 1)
}
DATEPICKWEEKSTARTDAY
;
$dg->add_event("jqGridAddEditAfterShowForm", $weekStartDay);

See Live Demo!

The post Set Start Day of the Week in Datepicker appeared first on phpGrid - PHP Datagrid.

]]>
9207