I have this code to display the date and time from a database. How do I change it to subtract 6 hours from a timestamp.
date('m-d g:Ga', strtotime($row['time_stamp']))
UNIX timestamps are seconds from the era. Just subtract the number of seconds in six hours:
date('m-d g:Ga', strtotime($row['time_stamp'])-21600)
You can also use strtotimeagain:
strtotime
date('m-d g:Ga', strtotime('-6 hours', strtotime($row['time_stamp'])))
Since in MySQL you can do MySQL for you:
SELECT DATE_FORMAT('...', DATE_SUB(time_stamp, INTERVAL 6 HOUR)) ...
MySQL, PHP strtotime(), , . strtotime , .
$ vindate = date ('H: i: s', strtotime ($ row ['ms_attend_time']) + 19800); echo $ vindate;