Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

GT::Date and getting the same day of week

Quote Reply
GT::Date and getting the same day of week
I have this code:

Code:


// Today's Date, e.g. Monday

GT::Date::date_set_format('%mmmm% %dd%, %yyyy%');
my $current_date = GT::Date::date_get(); // today's date



// Monday 2 weeks from this Monday
GT::Date::date_set_format('%mmmm% %dd%, %yyyy%');
my $update_date = GT::Date::date_add($current_date, 14);



print $update_date;


The problem is I want to always return the date that is on the SAME day of the week 2 weeks from this day. So if it's Monday Nov 10, the next one is Monday, Nov 24.

The problem is that adding 14 days is NOT accurate as the returned date seems to be off by 1 day sometimes (i.e. sometimes adding 14 days works sometimes you need to add 15 days).

Anybody know if this is due to the fact that some months have 31 days, if so is there a consistent way to get the same day 2 weeks from the current day of the week as a GT:: Date construct?
Quote Reply
Re: [scorpioncapital] GT::Date and getting the same day of week In reply to
I use this code fine;

Code:
my $date = GT::Date::date_get();
my $_date = GT::Date::date_sub($date,14);

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] GT::Date and getting the same day of week In reply to
I guess the question is if adding 14 days to any day of the week always results in the same day of the week 14 days forward or there are some special cases...