Class Format
Formatter methods for the DataTables Editor
All methods in this class are static with common inputs and returns.
Methods summary
public static
|
string
|
#
date_sql_to_format( $val, $data, $opts )
Convert from SQL date / date time format to a format given by the options
parameter.
Convert from SQL date / date time format to a format given by the options
parameter.
Typical use of this method is to use it with the DataTables\Editor\Field::getFormatter()
and DataTables\Editor\Field::setFormatter() methods of DataTables\Editor\Field where the parameters
required for this method will be automatically satisfied.
Parameters
- $val
string
$val Value to convert from MySQL date format
- $data
string[]
$data Data for the whole row / submitted data
- $opts
string
$opts Format to convert to using PHP date() options.
Returns
string
Formatted date or empty string on error.
|
public static
|
string
|
#
date_format_to_sql( $val, $data, $opts )
Convert from a format given by the options parameter to a format that SQL
servers will recognise as a date.
Convert from a format given by the options parameter to a format that SQL
servers will recognise as a date.
Typical use of this method is to use it with the DataTables\Editor\Field::getFormatter()
and DataTables\Editor\Field::setFormatter() methods of DataTables\Editor\Field where the parameters
required for this method will be automatically satisfied.
Parameters
- $val
string
$val Value to convert to SQL date format
- $data
string[]
$data Data for the whole row / submitted data
- $opts
string
$opts Format to convert from using PHP date() options.
Returns
string
Formatted date or null on error.
|
public static
|
string
|
#
datetime( $val, $data, $opts )
Convert from one date time format to another
Convert from one date time format to another
Typical use of this method is to use it with the DataTables\Editor\Field::getFormatter()
and DataTables\Editor\Field::setFormatter() methods of DataTables\Editor\Field where the parameters
required for this method will be automatically satisfied.
Parameters
- $val
string
$val Value to convert
- $data
string[]
$data Data for the whole row / submitted data
- $opts
string
$opts Array with from and to properties which are
the formats to convert from and to
Returns
string
Formatted date or empty string on error.
|
public static
|
string
|
#
explode( $val, $data, $opts )
Convert a string of values into an array for use with checkboxes.
Convert a string of values into an array for use with checkboxes.
Parameters
- $val
string
$val Value to convert to from a string to an array
- $data
string[]
$data Data for the whole row / submitted data
- $opts
string
$opts Field delimiter
Returns
string
Formatted value or null on error.
|
public static
|
string
|
#
implode( $val, $data, $opts )
Convert an array of values from a checkbox into a string which can be used to
store in a text field in a database.
Convert an array of values from a checkbox into a string which can be used to
store in a text field in a database.
Parameters
- $val
string
$val Value to convert to from an array to a string
- $data
string[]
$data Data for the whole row / submitted data
- $opts
string
$opts Field delimiter
Returns
string
Formatted value or null on error.
|
public static
|
string
|
#
nullEmpty( $val, $data, $opts )
Convert an empty string to null . Null values are very useful in
databases, but HTTP variables have no way of representing null as a
value, often leading to an empty string and null overlapping. This method will
check the value to operate on and return null if it is empty.
Convert an empty string to null . Null values are very useful in
databases, but HTTP variables have no way of representing null as a
value, often leading to an empty string and null overlapping. This method will
check the value to operate on and return null if it is empty.
Parameters
- $val
string
$val Value to convert to from a string to an array
- $data
string[]
$data Data for the whole row / submitted data
- $opts
string
$opts Field delimiter
Returns
string
Formatted value or null on error.
|
Constants summary
string
|
DATE_ISO_8601
|
"Y-m-d" |
#
Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd
Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd
|
string
|
DATE_ISO_822
|
"D, j M y" |
#
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
|
string
|
DATE_ISO_850
|
"l, d-M-y" |
#
Date format: Friday, 09-Mar-12. jQuery UI equivalent format: DD, dd-M-y
Date format: Friday, 09-Mar-12. jQuery UI equivalent format: DD, dd-M-y
|
string
|
DATE_ISO_1036
|
"D, j M y" |
#
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
Date format: Fri, 9 Mar 12. jQuery UI equivalent format: D, d M y
|
string
|
DATE_ISO_1123
|
"D, j M Y" |
#
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
|
string
|
DATE_ISO_2822
|
"D, j M Y" |
#
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
Date format: Fri, 9 Mar 2012. jQuery UI equivalent format: D, d M yy
|
string
|
DATE_TIMESTAMP
|
"U" |
#
Date format: 1331251200. jQuery UI equivalent format: @
Date format: 1331251200. jQuery UI equivalent format: @
|
string
|
DATE_EPOCH
|
"U" |
#
Date format: 1331251200. jQuery UI equivalent format: @
Date format: 1331251200. jQuery UI equivalent format: @
|