Try the following script:
<?php
$hora = date("G:a");
echo $hora;
?>
Select the G format to print the time without the initial 0, but print me 14: pm and on my computer it's 11: am, how do I synchronize php with my local time?
Try the following script:
<?php
$hora = date("G:a");
echo $hora;
?>
Select the G format to print the time without the initial 0, but print me 14: pm and on my computer it's 11: am, how do I synchronize php with my local time?
You must add your time zone to show the date (or before), there are several ways to do it, one of them is with DateTime :
$hora = new DateTime("now", new DateTimeZone('America/New York'));
echo $hora->format('G');
You could also use date_default_timezone_set :
date_default_timezone_set("America/New York");
echo date('G');
You can try the following;
<?php
$fecha = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
echo $fecha->format('Y-m-d H:i:sP') . "\n";
$fecha->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $fecha->format('Y-m-d H:i:sP') . "\n";
?>
Information that was obtained from the official PHP documentation link
If you only want to show the time of your server, you can do it in the following way:
<?php
echo date('h:i:s A');
?>