# Class Format

Formatter methods for the DataTables Editor

All methods in this class are static with common inputs and returns.

Namespace: DataTables\Editor
Located at Editor/Format.php

Methods summary
`public static string` | # `dateSqlToFormat( string $format, string $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 Field::getFormatter and Field::setFormatter methods of `DataTables\Editor\Field` where the parameters required for this method will be automatically satisfied. #### Parameters $format $val Value to convert from MySQL date format $opts,… Format to convert to using PHP date() options. #### Returns string Formatted date or empty string on error.
`public static string` | # `dateFormatToSql( string $format, string $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 Field::getFormatter and Field::setFormatter methods of `DataTables\Editor\Field` where the parameters required for this method will be automatically satisfied. #### Parameters $format $val Value to convert to SQL date format $opts,… Format to convert from using PHP date() options. #### Returns string Formatted date or null on error.
`public static string` | # `datetime( string $from, string[] $to, string $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 Field::getFormatter and Field::setFormatter methods of `DataTables\Editor\Field` where the parameters required for this method will be automatically satisfied. #### Parameters $from $val Value to convert $to $data Data for the whole row / submitted data $opts,… Array with `from` and `to` properties which are the formats to convert from and to #### Returns string Formatted date or null on error.
`public static string` | # `explode( string $char = '|' , string $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 $char $val Value to convert to from a string to an array $opts,… Field delimiter #### Returns string Formatted value or null on error.
`public static string` | # `implode( string $char = '|' , string $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 $char $val Value to convert to from an array to a string $opts,… Field delimiter #### Returns string Formatted value or null on error.
`public static string` | # `nullEmpty( string $val,…, string $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,… Value to convert to from a string to an array $opts,… Field delimiter #### Returns string Formatted value or null on error.
`public static string` | # `ifEmpty( string $ret, string $opts,… )` Formatter that can be used to specify what value should be used if an empty value is submitted by the client-side (e.g. null, 0, 'Not set', etc) Formatter that can be used to specify what value should be used if an empty value is submitted by the client-side (e.g. null, 0, 'Not set', etc) #### Parameters $ret $val Value to convert to from a string to an array $opts,… Empty value #### Returns string Formatted value or null on error.
`public static string` | # `fromDecimalChar( string $char = ',' , string $opts,… )` Convert a number from using any character other than a period (dot) to one which does use a period. This is useful for allowing numeric user input in regions where a comma is used as the decimal character. Use with a set formatter. Convert a number from using any character other than a period (dot) to one which does use a period. This is useful for allowing numeric user input in regions where a comma is used as the decimal character. Use with a set formatter. #### Parameters $char $val Value to convert to from a string to an array $opts,… Decimal place character (default ',') #### Returns string Formatted value or null on error.
`public static string` | # `toDecimalChar( string $char = ',' , string $opts,… )` Convert a number with a period (dot) as the decimal character to use a different character (typically a comma). Use with a get formatter. Convert a number with a period (dot) as the decimal character to use a different character (typically a comma). Use with a get formatter. #### Parameters $char $val Value to convert to from a string to an array $opts,… Decimal place character (default ',') #### Returns string Formatted value or null on error.

Constants summary
`string` | `DATE_ISO_8601` Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd Date format: 2012-03-09. jQuery UI equivalent format: yy-mm-dd | # `"Y-m-d"`
`string` | `DATE_ISO_822` 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 | # `"D, j M y"`
`string` | `DATE_ISO_850` 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 | # `"l, d-M-y"`
`string` | `DATE_ISO_1036` 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 | # `"D, j M y"`
`string` | `DATE_ISO_1123` 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 | # `"D, j M Y"`
`string` | `DATE_ISO_2822` 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 | # `"D, j M Y"`
`string` | `DATE_USA` Date format: March-. jQuery UI equivalent format: D, d M yy Date format: March-. jQuery UI equivalent format: D, d M yy | # `"m-d-Y"`
`string` | `DATE_TIMESTAMP` Date format: 1331251200. jQuery UI equivalent format: @ Date format: 1331251200. jQuery UI equivalent format: @ | # `"U"`
`string` | `DATE_EPOCH` Date format: 1331251200. jQuery UI equivalent format: @ Date format: 1331251200. jQuery UI equivalent format: @ | # `"U"`