Timezones and cron

I have a MySQL database containing details of shops in different time zones. The timezone of each store is stored in iana format and the MySQL datetimes are stored in UTC.

I wish to execute some php code at the end of the day for each shop.

This is how I am thinking to approach this but is there a better way?

  • Set a cron to run hourly at xx:59:59.
  • Get the current date at the top of the php script. Is the script guaranteed to get the correct date at 23:59:59?
  • Use SQL query to return all shops that are at the end of the current day. I'm not sure how to check this in the query?
  • Perform the end of the day processing on those stores.

  • You can run an hourly cron job any time you wish.
  • Why do you need the date here? You wrote that you're interested in the servers, which are at 23:59:59 localtime, so time is relevant, I think, not the date. Also, if your details server is very busy, your script might run too late and get the next day's date.
  • If IANA time zone format means offset to UTC, you could simply look for shops having a timezone like

    24 - current time(UTC) +/- DST
    

    Negative timezone offsets work similar, eg 24 + offset . So timezone offset -01:00 would become +23:00

  • Nothing to say here.

  • 链接地址: http://www.djcxy.com/p/66346.html

    上一篇: PHP脚本不能在Ubuntu服务器上作为cron作业运行

    下一篇: 时区和克朗