Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I want to be able to compare an input of $date, which is a string, with a value from the database with the type of "datetime". Here's my code below. It outputs as a string type instead of the desired datetime type. Can you please help me out?

<?php
  $string="2013-04-19 14:08:10";
  $timestamp = strtotime($string);
  $date = date("Y-m-d H:i:s", $timestamp);
?>
<?php var_dump($date);?>

this is the output

string '2013-04-19 14:08:10' (length=19)

Thanks so much for your help.

share|improve this question
    
What DBMS are you using? –  Kermit Apr 26 '13 at 22:23
add comment

1 Answer

for MySQL datetime data type you can use:

$date = new \DateTime('2013-04-19 14:08:10');
share|improve this answer
    
This does not answer the question of how it should be compared to the SQL datetime. –  Kermit Apr 26 '13 at 22:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.