I’ve got a webapp (using php), my clients are java-based and are submitting dates to me using:
System.currentTimeMillis();
so my web app gets it via a post, so it’s a string, like:
$submittedTime = "9734367890508";
I want to insert it into a mysql table field, I think either a DATETIME or TIMESTAMP field can store it.
What type of field should I use, and how do I get that submitted value into the mysql table such that I can do queries later on using all the mysql time functions?
Thanks
To use it with PHP, you’ll have to divide it by 1000 to turn it into seconds. Once it’s in seconds, you can format it with the
date()command, like so:Having said that, what’s wrong with just using the time from PHP or MySQL themselves? It’s be the same date call in PHP, but without the second argument; or just setting the value to
NOW()in MySQL.