function visitors_sqlite_date_format_sql in Visitors 8.2
Same name and namespace in other branches
- 8 visitors.module \visitors_sqlite_date_format_sql()
- 7.2 visitors.module \visitors_sqlite_date_format_sql()
- 7 visitors.module \visitors_sqlite_date_format_sql()
Set date format for sqlite sql query.
Parameters
$field_name string field name:
$format string date format:
Return value
string date format
1 call to visitors_sqlite_date_format_sql()
- visitors_date_format_sql in ./
visitors.module - Set date format for sql query.
File
- ./
visitors.module, line 160 - Logs visitors for your site.
Code
function visitors_sqlite_date_format_sql($field_name, $format) {
static $format_array = array(
'%H' => "strftime('%%H', %s + (%d), 'unixepoch')",
'%a' => "case strftime('%%w', %s + (%d), 'unixepoch')\n when '0' then 'Sun'\n when '1' then 'Mon'\n when '2' then 'Tue'\n when '3' then 'Wed'\n when '4' then 'Thu'\n when '5' then 'Fri'\n when '6' then 'Sat'\n else '' end",
'%w' => "strftime('%%w', %s + (%d), 'unixepoch')",
'%d' => "strftime('%%d', %s + (%d), 'unixepoch')",
'%Y %M' => "strftime('%%Y ', %1\$s + (%2\$d), 'unixepoch') ||\n case strftime('%%m', %1\$s + (%2\$d), 'unixepoch')\n when '01' then 'January'\n when '02' then 'Febuary'\n when '03' then 'March'\n when '04' then 'April'\n when '05' then 'May'\n when '06' then 'June'\n when '07' then 'July'\n when '08' then 'August'\n when '09' then 'September'\n when '10' then 'October'\n when '11' then 'November'\n when '12' then 'December'\n else '' end",
'%Y%m' => "strftime('%%Y%%m', %s + (%d), 'unixepoch')",
);
if (isset($format_array[$format])) {
$diff = visitors_timezone_diff();
$result = sprintf($format_array[$format], $field_name, $diff);
}
else {
$result = '';
}
return $result;
}