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 #172418 is a reply to message #172416] Thu, 17 February 2011 04:12 Go to previous messageGo to previous message
TAXI is currently offline  TAXI
Messages: 3
Registered: February 2011
Karma:
Junior Member
Am Thu, 17 Feb 2011 01:49:52 +0000
schrieb Denis McMahon <denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com>:

> On 17/02/11 00:51, TAXI 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 <taxi(at)a-city(dot)de>:
>>
>>> Hi,
>>> I write this couse of http://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. :)
>
> The best solution is probably using crontab to schedule your job to
> run at the same time each month, eg 03:27 on the 3rd
>
> Failing that, you could use a semaphore file and the getdate,
> filemtime and touch functions, like this:
>
> <?php
>
> $sf = "semaphore-file-name";
> $newmonth = false;
> $last = @filemtime($sf);
> if ($last) {
> $then = getdate($last);
> $now = getdate();
> if ($then["mon"] != $now["mon"]) {
> $newmonth = true;
> }
> }
> else {
> $newmonth = true;
> }
>
> if ($newmonth) {
> touch($sf) or die "unable to modify file\n";
> // do once a month stuff
> }
>
> ?>
>
> Rgds
>
> Denis McMahon

Thank you, but that's not what I need. Your script would execute the
action at the first day of every month.
I want it exactly after one month, so when it's executed today the
first time the next execution should be the 17.03.2011, then the 17.04.
and so on. But the execution of the first time isn't static, too.
[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: Tue Nov 26 21:07:36 GMT 2024

Total time taken to generate the page: 0.03782 seconds