Hello, I am really sorry for posting this here but I couldn't find anything
simular to the net. I need to insert datetime values into my mysql
db and in particular the current time second and minute value
and than I want to call this value and do a $current_time-$mysql_time
something like this and display just the minutes.
Thx in advance.

Member Avatar for diafol

checkout the online php and mysql manuals - loads of info there. It is suggested that you store this info as a unix timestamp (integer). You can use now() in mysql statements for current time.

checkout the online php and mysql manuals - loads of info there. It is suggested that you store this info as a unix timestamp (integer). You can use now() in mysql statements for current time.

Like 1 minute after I posted here I saw that with NOW() thx though
but whenever I do soemthing like
$timeleft=$time_fromdb-$NOWtime I get always 0 I dunno why.

Member Avatar for diafol

not $now - now()! ANd in sql statement not in php.

BUT you can do this:

"SELECT TIMEDIFF(mydatetime,now())"

This takes the first datetime and subtracts the second datetime.

You can download the mysql manual from here:

http://dev.mysql.com/doc/

Look up Date and Time Functions

use it as

<?
$mydate= date('Y-m-d m:i:s'); 
OR
$mydate= gmdate('Y-m-d m:i:s'); 
?>

and use $mydate variable where you want to use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.