Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8133661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:41:09+00:00 2026-06-06T09:41:09+00:00

I searched around but couldn’t find exactly what I’m looking for. I have a

  • 0

I searched around but couldn’t find exactly what I’m looking for.

I have a PHP Settings page where Admins from my site are able to select an hour of the day for a daily Cron Job script to execute. In my crontab I have the script running every hour. When the script runs, it checks to see if the current hour is equal to the hour that the settings page requested.

The reason I did it like this is because I absolutely could not figure out a way to edit the crontab file via PHP, despite doing a lot of testing and research on the subject matter. Bonus points if you can help me figure out a way to do this.

The real reason I am creating this question is because I am having some issues with my Unix server’s ` time. When on my localhost machine (IIS), the Cron script is executing each hour like it’s supposed to, but when I moved everything over to my Unix Amazon machine, the time is off by exactly five hours.

The Cron job is still running hourly like it’s supposed to, but when the PHP script checks to see if the current time (using date("G")) matches the settings time, it will not work like intended. Sure, it will eventually get processed exactly five hours too late.

I don’t think it’s a coincidence that I live in the Central timezone, which also happens to be five hours off, so I’m nearly positive it is related to that.

I could write a work-around that will always offset the time by five hours, but this will cause my date fields to be inaccurate (I think) and it’s kind of a stretch. I’d rather just ask on SO because I’m sure that a lot of people are reading this and thinking that I’m stupid for not knowing the answer.

One more thing:

I have this line of code in my scripts. Anything else I need to share?

date_default_timezone_set('America/Chicago');

EDIT: An explanation of what your “fix” is would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:41:10+00:00Added an answer on June 6, 2026 at 9:41 am

    There are a few questions being asked here I’d say, to answer them all would take some time, but I’ll try to skim through as much as possible.

    • To edit the crontab, you’ll need to edit the crontab for the webserver user not the root user, or if you intend to edit the root crontab you’ll need to configure sudo so the webserver user can edit that crontab specifically. The paradigm you have in place is probly better, just to install a single cron then put the bulk of your logic into the PHP script invoked by the cron.
    • The issue you’re running into w/ the php date being different is def a dupe of the other thread as suggested by the first comment. If you have access to php.ini you should set date.timezone accordingly there. Also, if the users aren’t in the timezone the box is running in, you’ll have to adjust for a timezone offset no matter what.
    • Another thing to mention just in passing is that you can get the date value from the OS through PHP via something like $sLinuxDate = shell_exec('date');. Probly you want to get the timezone between PHP & the OS set correctly via php.ini as I mentioned though.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched it all around but couldn't find it all i want to
I've searched around for pointers on this question but couldn't find any. Suppose I
I've searched around, and saw some tips, but still couldn't find the solution to
I searched, but surprisingly couldn't find an answer. I have a long NSString that
I searched the site already but couldn't find any suitable information. As there is
I've searched around on a lot of forums but have yet to find an
I searched old questions, but couldn't find an answer or wrap my head around
I searched around but couldn't find an answer. I'm not sure if this is
I've searched around for a solution to my problem but couldn't find one so
I searched around but couldn't find a solution for my dll issue. My solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.