FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » mktime() changes days when it should't
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: mktime() changes days when it should't [message #172433 is a reply to message #172415] Thu, 17 February 2011 22:34 Go to previous messageGo to previous message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma:
Senior Member
On Feb 17, 12:51 am, TAXI <t...@a-city.de> wrote:
> Sorry, I have forgotten someting:
> Bevore somebody asks why I need this: I want to write a script which
> does an action every month. For that I save the timestamp of the last
> execution and now I need a save way to check if one month is over. But
> couse different months doesn't have the same amount of days I can't
> simply count the secounds 30 days have and calculate with this.
>
> Am Thu, 17 Feb 2011 01:43:39 +0100
> schrieb TAXI <t...@a-city.de>:
>
>
>
>> Hi,
>> I write this couse ofhttp://bugs.php.net/bug.php?id=54005- As you
>> can see Derik says it's not a bug (in PHP itself) and links me to
>> here for support.
>
>> P.S. Couse of Deriks last sentence I changed the script so that it
>> passes 0 as hour to mktime() but that doesn't change anything.
>
>> P.P.S. Sorry for my bad english. :)

When I need to do this (and I had to within the last 2 weeks), I use a
MySQL table to store the run date and then use the mysql date
functions to calculate the next date on which I need to run (it is
simple to add a month in MySQL). I then run a small cron job daily
which checks the table to see if it is required to do anything that
day. If not the job just exits.

However you need to think about how what you seem to want to do can be
achieved. What happens if the first event occurs on the 29th, 30th or
31st of a month. What will you expect ro happen when the next
scheduled date should be in a month that doesn't have a 29th, 30th or
31st? If you can state this I can help you more. As it is your
requirement is incomplete and impossible to fulfil.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Almost done - Just need a way to assign a variable
Next Topic: Grate opportunities to earn money from online!
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Oct 05 23:10:37 GMT 2024

Total time taken to generate the page: 0.04165 seconds