Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Akeno's avatar

Homestead - wrong time

Hi,

When I'm running my page on homestead, the time is incorrect.

If it's 12:38 in my timezone, homestead says it's 12:20.

I have no idea why? Do you know how I could change this?

Thanks

0 likes
21 replies
Ionut's avatar

Did you check the timezone setting in app.php ?

    /*
 |--------------------------------------------------------------------------
 | Application Timezone
  |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
   | ahead and set this to a sensible default for you out of the box.
   |
    */

 'timezone'        => 'Europe/Rome',
1 like
Akeno's avatar

Yes, I checked it. It' correct.

It's kind of strange. It worked before I switched to homestead

bashy's avatar

You can check the Unix system date/time with this command

date

To set the time, you can do one of a few things but in your situation I think it's the wrong time set, not timezone.

Use this to update it to the correct time, replacing HH with the hours (24 hour), MM with minutes and SS with the seconds

date +%T -s "HH:MM:SS"
1 like
Akeno's avatar

Hm, after restarting homestead The time is off by 4 minutes, not 18 minutes like before.

That's what PHP outputs: 29.12.2014, 15:22:42 Uhr

That's what the console outputs: Mon Dec 29 14:22:42 UTC 2014

Actual time: 14:26:22

The difference between homestead and the actual time differs from time to time. Very strange

Thus I think, adding some minutes to the time is not the answer

bashy's avatar

Okay, PHP timezone is out but the system time is actually behind.

What are you doing that requires the correct (current) time?

Akeno's avatar

Well, I have a script that tells you e.g. when the upgrade of a building will be finished. And that should be the real time. Because if the real time 12:00am and it says you the building will be finished at 11:58am you think that's a bug or something. That's just not that pretty.

bashy's avatar

Have you set the timezone in php.ini and set the date with that command?

It's pretty normal to update the system time.

1 like
Akeno's avatar

Ehm I had a typo before: The console's output time is 1 hour off. It's UTC, I'm in UTC-+1

How can I access my php.ini in homestead?

EDIT: I restarted again and now it's off by 3 seconds. It's really strange. But even 3 seconds seems bad. It should match exactly.

bashy's avatar

Strange, it's perfect on my Vaprobash VM. Never had to set it either.

Not sure what else to suggest.

Akeno's avatar

Okay, I might have a possible answer:

After restart the time's off by just some seconds. Then set my computer to standby for 10 minutes. After that, the time's off by exactly 10 minutes.

bashy's avatar
bashy
Best Answer
Level 65

Ah, sleep/standby/hibernation will do that. The time should update though, not sure what the sync time on Homestead is but on my Vagrant install, it's 10 seconds.

3 likes
Akeno's avatar

Do you know how I can change this interval?

Akeno's avatar

Hm, okay. My vagrant file looks quite different and It throws an error when I paste the line in.

I'll check the internet for possible was to change it.

Thank you :)

bashy's avatar

Yeah Homestead is a little different. One reason why I don't use it is that it's too "standard" / "mainstream" :P

davemcl's avatar

Back in the early days of virtualisation time syncing was always an issue and we always ran NTP with regular updating. I thought the development of synthetic drivers for this problem solved the issue however...

1 like
sgelbart's avatar

My time keeps falling behind so I run: sudo ntpdate ntp.ubuntu.com That works but it'll fall behind again soon after. Not sure what it is maybe debugger...

1 like
danielcoimbra's avatar

Try these steps:

1 - vagrant ssh (into Homestead VM)

2 - sudo dpkg-reconfigure tzdata (and choose your region)

4 likes
lindstrom's avatar

The last 6.* release introduced this issue for me. Since 7 was out, I just rebuilt and the issue is gone.

Please or to participate in this conversation.