PHP ミリ秒タイムスタンプ取得方法【初心者向け】

  1. microtime関数を利用する。
$time = microtime(true) * 1000;
echo $time;
  1. DateTimeクラスを使用します。
$dateTime = new DateTime();
$milliseconds = $dateTime->getTimestamp() * 1000 + round($dateTime->format('u') / 1000);
echo $milliseconds;
  1. gmdate関数を使用する:
$milliseconds = gmdate('U') * 1000 + round(gmdate('u') / 1000);
echo $milliseconds;
bannerAds