Forum Moderators: coopster

Message Too Old, No Replies

A Time logic issue

         

Shadi

3:02 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



am not sure if am allowed to post such a question on here but am having a slight logic problem...
i need my script to provide me with a specific date ($mydate). now here are the requirements:

the script runs daily. the date that the script needs to calculate is always the next monday e.g. if the script ran today (28/8/2003) it will use the date 1/9/2003 for this monday coming. now it needs to do every day apart from sunday on a sunday it needs to get the next monday. e.g. if i ran it this sunday (31/8/2003) it will need the date (8/9/2003) you follow me? :)

i for some reason can't get my heard round a simple efficiant way to do this, any help would be appreciated!

thanks

Robber

11:37 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



Its not something I've had to do but I'd take a look at the date functions at [uk.php.net...] where you'll find you can quite easily extract the current day. Once you have that it should be pretty straight forward to work out where the next monday is relative to where you are now.

Shadi

1:27 am on Sep 1, 2003 (gmt 0)

10+ Year Member



Well am sorta doing this in Perl, i think the PHP people on this site are better than the Perl ones ;) and was hoping to get the logic worked out so i can convert it to Perl myself.

IanKelley

8:57 am on Sep 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you're trying to create a future date in perl, you're looking in entirely the wrong place :-) There's no work to be done in either language, you just need two functions in each language and they are completely different.

Here's the basic idea of what you want in perl:
($sec,$min,$hour,$mday,$mon,$year,$wday) = (gmtime(time()+592200))[0,1,2,3,4,5,6];

That's the date/time one week from today.