eNarc
asked on
get results between a php timestamp 1206858612
hi is there anyway of getting results from mysql from a php timestamp? 1206858612
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I just got this from the PHP manual...
check if it is helpful to you
check if it is helpful to you
$str = 'Not Good';
// previous to PHP 5.1.0 you would compare with -1, instead of false
if (($timestamp = strtotime($str)) === false) {
echo "The string ($str) is bogus";
} else {
echo "$str == " . date('l dS \o\f F Y h:i:s A', $timestamp);
}
@eNarc
From my experience, the only time I use timestamp is when getting the difference between two dates
i.e.
convert date 1 & date 2 to timestamp
difference = date2 - date1
after which its comverted back using date()
When using MySQL, I always have the date in the format YYYY-MM-DD HH:MM:SS
I would go with bportlock's suggestion and convert to this format using the date() function
$mySqlDate = date("Y-m-d", 1206858612 );
then use that in your query
From my experience, the only time I use timestamp is when getting the difference between two dates
i.e.
convert date 1 & date 2 to timestamp
difference = date2 - date1
after which its comverted back using date()
When using MySQL, I always have the date in the format YYYY-MM-DD HH:MM:SS
I would go with bportlock's suggestion and convert to this format using the date() function
$mySqlDate = date("Y-m-d", 1206858612 );
then use that in your query
ASKER
Perfect
$mySqlDate = date("Y-m-d", 1206858612 );
or more generally....
$timestamp = 1206858612;
...... other code......
$mySqlDate = date("Y-m-d", $timestamp );