Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want some user (or some process) to have different time and date. Is it possible?

How can I do this?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

What RunAsDate does is the following:

RunAsDate intercepts the kernel API calls that returns the current date and time (GetSystemTime, GetLocalTime, GetSystemTimeAsFileTime), and replaces the current date/time with the date/time that you specify.

Under Linux you have some options to accomplish the same thing:

  1. If you can get a Windows version of the program, you might be able to run RunAsDate under Wine (but watch out for a recent bug).

  2. Find a wrapper library to do this, or write your own. Some options are given below.

  3. Use a Virtual Machine. This is overkill, but since an OS in guest VM is completely separate from the underlying host, you can set it's system time to something completely different. It may be quicker to setup than the other options.


Option 2 can be accomplished by different methods, depending on the what you're trying to run. DaveParillo's answer below links to a DIY approach that explains the different methods and includes code for an executable. Some other options include:

share|improve this answer
    
+1 i especially liked the wine answer. –  DaveParillo Oct 24 '09 at 20:15
    
+1 covers every solution I can think of :) –  Lee B Oct 24 '09 at 22:04
    
I wish I could up vote this again - like the datefudge update! –  DaveParillo Oct 25 '09 at 1:36

Is this what you are trying to accomplish?

Linux, UNIX set the time zone on a per user basis

share|improve this answer
    
as the link title suggests, that only sets the timezone on a per user basis, but won't change the system time for that user. –  quack quixote Oct 24 '09 at 18:02

You can set the TZ to just about any value you want. The system time is unaffected, but the apparent time will change. This is not the same as intercepting the kernel, but requires no coding. Use (3 letter identifier)(offset from UTC h:m:s)[(summer time identifier)(summer offset from UTC h:m:s)]. For example: TZ=XXX[+-]hh:ss:ssYYY[+-]hh:ss:ss the second (summer) set is optional.

date; export TZ=FOO+23:11:17; date; export TZ=; date

returns:

Sat Oct 24 20:01:55 UTC 2009
Fri Oct 23 21:01:11 FOO 2009
Sat Oct 24 20:01:55 UTC 2009

Although I may regret this, here is an example program that you could compile to mod your kernel and completely fake out all or just selected programs about the date.

share|improve this answer
    
actually that's a great link, thx -- one of the comments to that post led me to the existing programs i mentioned in my edit. –  quack quixote Oct 24 '09 at 21:32
    
Do not mess with the overall system time; it's pretty important that files are created with the correct date etc. –  Lee B Oct 24 '09 at 22:01
    
Also, Timezones only support +/- 24 hours, afaik. The kernel mod for "selected programs" is still a good suggestion, but datefudge is probably the simpler method for most apps. –  Lee B Oct 24 '09 at 22:03
    
the link mentions kernel modding but doesn't go into much detail; the code it provides uses the catch-a-system-call (run-in-container) method -- basically the same thing datefudge does. –  quack quixote Oct 24 '09 at 22:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.