Virus causing wrong date to display

80 views Asked by At

I have a basic php script

<?php

$today = date("Y-m-d");

echo $today;

?>

Which should output 2014-11-14. However, I am getting output of 2014-11-15 even though my system tray displays 2014-11-14.

I changed the system date back one day (13th) and I got the output I wanted (14th)... Earlier today I had to do a system restore and ran Malwarebytes because I picked up a virus. Could this be the cause of this?

Does anyone know where else I can check my systems time other than the system tray?

2

There are 2 answers

0
Rizier123 On

date() function uses unix timestamps which always is set to +0:00

So use:

date_default_timezone_set('Europe/Zurich');

When you set your default timezone it will automaticly calculate the offset!

0
Stanley On

the date() function is returning UTC time and not the time on your local computer