Is there a PHP function that returns the date and time in the same format as the MySQL function NOW()
?
I know how to do it using date()
, but I am asking if there is a function only for this.
For example, to return:
2009-12-01 00:00:00
Is there a PHP function that returns the date and time in the same format as the MySQL function NOW()
?
I know how to do it using date()
, but I am asking if there is a function only for this.
For example, to return:
2009-12-01 00:00:00
Try this:
Use
strftime
:%F
is the same as%Y-%m-%d
.%T
is the same as%H:%M:%S
.Here's a demo on ideone.
You can use the PHP date function with the correct format as the parameter,
MySQL function
NOW()
returns the current timestamp. The only way I found for PHP is using the following code.