Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change today's date and time in php

Tags:

Is it possible to change php's current date and time (something like set_time(strtotime('1999-09-09')) so when i call time() it will return me timestamp for 1999-09-09? I need to set it globally for whole app.

EDIT

I already have one old app and i need to make possible to set up current date. I can't accept any custom functions. Imagine i should review all the code and replace every time() call. Even if i'll do so then it will not help because there are functions like getdate() which i need to replace as well.

like image 458
vooD Avatar asked Oct 13 '10 12:10

vooD


People also ask

How can I get current date in YYYY-MM-DD format in PHP?

$date = date("yyyy-mm-dd", strtotime(now));

How can I insert current date and time in PHP?

Answer: Use the PHP date() Function You can simply use the PHP date() function to get the current data and time in various format, for example, date('d-m-y h:i:s') , date('d/m/y H:i:s') , and so on.


1 Answers

You could also check the Timecop PHP module, worked perfectly in my case.

After installing it, you can travel back & forth in time with just one line of code.

like image 179
zmf Avatar answered Sep 27 '22 17:09

zmf