-1

I am developing PHP/Apache/MySQL based code on my Windows 10 laptop via Windows Subsytem For Linux.

I am working on some code that is time related. It has a mix of PHP date commands, and MySQL "NOW()" calls. I need to be able to work on this at any time, not just within the dates given in my database records.

I could set my Windows system clock and prevent it updating, but then using the Internet becomes almost impossible, as does any SSH connection as the clocks won't be in sync so secure connections won't work.

I need to time travel.

Without messing with all my data to change the end dates of thousands of records, anyone know of a simple / common way for me to have PHP and MySQL running via WSL on Windows 10, think that the date is something other than it is?

closed as off-topic by joeqwerty, Jim B, kubanczyk, womble Jun 30 '18 at 2:38

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – womble
  • "Questions should demonstrate reasonable business information technology management practices. Questions that relate to unsupported hardware or software platforms or unmaintained environments may not be suitable for Server Fault - see the help center." – joeqwerty, Jim B, kubanczyk
If this question can be reworded to fit the rules in the help center, please edit the question.

1

Because WSL is not a virtual machine, it's always going to be tied to your underlying system time. If modifying your system time on demand is too cumbersome, you only have two options as far as I can see.

  1. Move the running code you're testing to an actual VM where you can modify the system time.

  2. Use some sort of test framework that allows mocking calls to date related functions. How to achieve that via PHP is probably a better question for stackoverflow.com though.

  • Thanks - hadn't considered a VM to be honest, and now feel pretty dumb. That seems the most likely solution. – Hippyjim Jun 29 '18 at 19:32
  • actually you have another better solution – phuclv Jul 8 '18 at 2:13

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