Is it possible to get the System date?

Hi, i tried this function

$date = date('m/d/Y h:i:s a');

but it is difference in the date of my PC…how can i get the system date of my PC.

THank you in advance.

Is your PHP code running on your PC, or from a server?

Hi fretburner thank you for the reply,…running from my PC

PHP only gives the time of your server. You need JS to get the time of the user’s computer. E.g.

If you want to make sure that your local server (on your PC) is displaying the right time, check that you have the correct timezone set for PHP.

You can change the global default for your system in your php.ini file (look for ), or you can set in on a per-script basis with the [fphp]date_default_timezone_set[/fphp] function:


// Example
date_default_timezone_set('Europe/London');

You can check PHP’s list of supported timezones to find the correct setting for your location.

Hi ralph, thank you for the reply,Okay so i cannot get the time of pc if i use the date function…Okay i will try this thank you for this :slight_smile:

Hi fretburner, Okay i will try this thank you again. :slight_smile:

Hi fretburner, Thank you so much for helping me…it’s working it coincide now to my PC…:slight_smile: :nanaman:

Hello,
Try this code
date_default_timezone_set(‘Europe/London’);
echo date(‘m/d/y h:i a’, time());