Closed (fixed)
Project:
Date
Version:
6.x-2.0-rc3
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Sep 2008 at 13:22 UTC
Updated:
7 Dec 2008 at 11:52 UTC
Using date, views, calendar, cck modules to create various date related calendars and views .
How can I force a test date (i.e. change what 'now' is) to test the site for different dates e.g. to check that blocks that only show on certain dates work correctly?
Comments
Comment #1
dwwThat's outside the scope of Drupal. I believe you'd have to change the time on your system clock for the server running your site. Might not be possible, unless you've got a virtual host or something.
Comment #2
Tony Sharpe commentedThanks for this. Changing the system clock is not something I want to do as it could cause all sorts of problems. I'd be quite happy to just hack in a line to date or calendar module as a one-off test - it's not something I'll need to do very often but I'd need to know the best place to do that.
Comment #3
dwwThat's what I'm saying -- you can't really do that. DateAPI is doing all sorts of date manipulation, sometimes directly via the database and/or PHP, both of which are going to be relying on the system clock for "now"...
One thing you could try is changing the date_now() function in date_api.module. I won't promise that'll cover all cases, but it'll cover most cases. ;) So, instead of this:
you'd want something like this:
or, just something like:
Again, I'm not positive that *every* time CCK date and DateAPI touch the current time they use a date object from date_now(). I believe there are cases where they generate SQL for NOW(), and that's going to not work unless your DB thinks the time is different, too...
Good luck,
-Derek
Comment #4
Tony Sharpe commentedThanks very much for this, I will give it a try. It's just what I needed.
Comment #5
karens commentedIt would be nice to find a way to do this, it's something that would be handy. I don't know off the top of my head if this will work or if there's another way to make this work, but I'll turn it into a feature request and if anyone finds a way to do it you can post it.