I would like display the right timestamp of my query. The date in my database is this one and date timestamp is set in Europe/Berlin. That is in my server setup and I always get this result.
2017-05-26 09:05:58
I want to display the date from my query. here is the code of my query
select logs.action_date_time from AuditLogs
How can I convert the logs.action_date_time date in my place here in Philippines? I supposed to see this result
2017-05-26T09:05:58+02:00
I search it in google the unix_timestamp but I don't see any sample that they use in select before from query. I'm using symfony for this. I just give summary of what the result of my above sample code.
const SELECT =
'SELECT logs.id, logs.object_id AS objectId, logs.object_type AS objectType, logs.object_name AS objectName, '.'logs.action, logs.action_date_time AS actionDateTime, logs.action_status AS actionStatus, logs.subject, logs.user, '.'logs.description, logs.ip, logs.param03_value AS userId, logs.param04_value AS userDisplayName ';
public function getNext($params)
{
// Hardcode for now
$limit = $params['limit'] ? (int) $params['limit'] : self::DEFAULT_LIMIT;
$limit++;
$select = self::SELECT;
$whereClause = $this->constructWhereClause($params);
$sql = "
$select FROM spoke.audit_logs AS logs
$whereClause
ORDER BY logs.action_date_time DESC, logs.id DESC
LIMIT $limit";
if ($params['cursor']) {
$now = new \DateTime();
$datetime = $now->getTimestamp();
if (isset($params['datetime'])) {
$datetime = $params['datetime'];
}
$whereClause = $this->constructWhereClause($params, 'logs1', false);
$sql = "
$select
FROM spoke.audit_logs logs1, spoke.audit_logs logs
WHERE logs1.id = logs.id
$whereClause
AND logs1.action_date_time <= '$datetime'
AND (logs1.id < {$params['cursor']} OR logs1.action_date_time < '$datetime')
ORDER BY logs1.action_date_time DESC, logs1.id DESC
LIMIT $limit";
}
$stmt = $this->getEntityManager()->getConnection()->query($sql);
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}