You are here

private function JsonLogData::setTimestamp in JSONlog 8

Same name and namespace in other branches
  1. 8.2 src/Logger/JsonLogData.php \Drupal\jsonlog\Logger\JsonLogData::setTimestamp()
  2. 3.x src/Logger/JsonLogData.php \Drupal\jsonlog\Logger\JsonLogData::setTimestamp()

Helper function to set timestamp in milliseconds.

1 call to JsonLogData::setTimestamp()
JsonLogData::__construct in src/Logger/JsonLogData.php
JsonLogData constructor.

File

src/Logger/JsonLogData.php, line 222

Class

JsonLogData

Namespace

Drupal\jsonlog\Logger

Code

private function setTimestamp() {
  $millis = round(microtime(TRUE) * 1000);
  $seconds = (int) floor($millis / 1000);
  $millis -= $seconds * 1000;
  $millis = str_pad($millis, 3, '0', STR_PAD_LEFT);
  $this->{'@timestamp'} = substr(gmdate('c', $seconds), 0, 19) . '.' . $millis . 'Z';
}