This is Unix timestamp representing the date.
Getting time with PHP/mySQL and wordpress plugin
Question
I got a little problem over here. It's about wordpress plugin but support will probably answer me in 1-2days. Maybe someone over here know the answer.
I am using myCRED plugin. It gives mi permission to give some user points on my website. So when I am giving someone points via wordpress panel then in mySQL table there is a column "time". Could someone figure this out?
Date -> php code entry in "time" column
April 24, 2014 4:28 pm -> 1398356897
April 24, 2014 3:27 pm -> 1398284766
April 23, 2014 4:30 pm -> 1398270617
I want to make php script which will add record to this table but I don't know how to fill "time" column corectly. Anyone here know function for this?
That's what I tried //you shouldn't really care about other variables. Just about the last one column called "time".
$time = time();
mysql_query("INSERT INTO wp_myCRED_log (user_id, creds, entry, time)
VALUES (".$_POST['user_id'].", '-".$_POST['price']."', 'Bought:".$_POST['reward']."', '".$time."' ; )");
If you still don't know what I mean just ask :)
Regreds, Guy with a problem.
Solution 2
OTHER TIPS
You will need to use php's Time() function to get the current unix timestamp.
i.e.
$time = time();
and then insert the $time variable into your query.
Use "$time" in your query since php will take the $ literally in single ticks, and use date(); as need to display this as a date.
mysql_query("INSERT INTO wp_myCRED_log (user_id, creds, entry, `time`)
VALUES (".$_POST['user_id'].", '-".$_POST['price']."', 'Bought:".$_POST['reward']."', '".$time."' ; )");