0

This Screenshot Date Time My Laptop..

enter image description here

This Screenshot My Script Result

enter image description here

This My Syntax

<?php
session_start();
$time = date('Y-m-d, H:i:s');
echo $time;
?>

Why not same.. Please Help Me.. Sorry My English Language Is Bad And I'm Newbie

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Ryan Christian
  • 59
  • 1
  • 2
  • 11

3 Answers3

1

here is something you need to see ....

<?php
$date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";

$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->format('Y-m-d H:i:sP') . "\n";
?>

http://php.net/manual/de/datetime.settimezone.php

Milos Lulic
  • 627
  • 5
  • 22
0

PHP 5.1 returns the time of the SERVER, which can be anywhere in the world.

Your computer displays your LOCAL time (or whichever time zone you set it up as, typically your local time zone).

Use Milos' solution to tell PHP what timezone you want to use. But many people will recommend using a timeserver for 100% accuracy, as your Server (as well as your computer) may not be set correctly itself.

See http://www.kloth.net/software/timesrv1.php for timeserver examples.

George Langley
  • 453
  • 4
  • 12
0

Please try this.

 <?php

 $date_time = new DateTime();
 echo $date_time->format('Y-m-d H:i:s');
 ?>
RichestSoft
  • 156
  • 1
  • 4