0

i have a function that uses current timestamp to fetch some data and sql table, but some data get's doubled because the are in the same second and runs twice.

I need to fetch them with timestamp including miliseconds.

i use

$timestamp = date_format($date, 'Y-m-d H:i:s');

is there anything like:

$serverTime = date_format($date, 'Y-m-d H:i:s:milisecs');

I tried to inlcude milisecs with microtime() in $timestamp but had no luck until now.

user3127632
  • 377
  • 5
  • 20

2 Answers2

0
$t = microtime();
echo $t;

This one works for me, i get the milliseconds and the current timestamp. Wheres your problem?

Realitätsverlust
  • 3,752
  • 2
  • 19
  • 42
0

Use the DateTime->format().

<?php
    $date = new DateTime();
    echo $date->format('Y-m-d H:i:s.u');
?>
tjati
  • 5,069
  • 3
  • 31
  • 49