views:

616

answers:

5

Hello,

Is there any PHP function that returns time format as the MySQL fuction NOW()

I know how to do it using date() .. but I am asking if there is a function only for this.

e.g.

"2009-12-01 00:00:00"

+6  A: 

Not besides date("Y-m-d H:i:s")

troelskn
+2  A: 

date('Y-m-d H:i:s')

Look here for more details: http://pl.php.net/manual/en/function.date.php

hsz
A: 
date("Y-m-d H:i:s", time());  
streetparade
You don't really need the second parameter.... waste of 6 characters IMO.
Chacha102
Right, if you waste characters like that, we're going to run out of them.
Bill Karwin
yep my bad the time() is actualy not needed
streetparade
A: 

There actually is a function exactly for this. Its called MySQL_NOW(). There is only one thing you have to do to get access to this PHP function.

Put this at the bottom of your script:

function MySQL_NOW(){ return date('Y-m-d H:i:s'); }

In reality, PHP, as with many other languages, doesn't like to create many functions with a specific program in mind. Those are reserved for libraries. So, if the function isn't in the php.net/mysql library, it probably doesn't exist.

Chacha102
+1  A: 

No there is no built-in equivalent of Date() function in PHP. You can only use date() function.

JCasso