选择datetime> now()的数据库? [关闭]

I have 2 questions:

  1. How can i select the data from the database where datetime>now() by writing php code?

  2. if there is the data from the database where datetime>now() , i want select the last two value from the database. what should i do?

I'm doing my gps tracking website. At the moment,my page is just select the last data to show the last position on the map. What i want is ,when i login my page, i will see the final position of the vehicle, and if the vehicles moves(mean the datetime of the data in database>now(), i want to select the 2 last updated data frequently to caculate the distance

  1. Store now() in a variable and then compare using where clause.

Also see this and this

Update :<?php $timeZone = 'Asia/Kolkata'; //variable for indian timezone date_default_timezone_set( $timeZone); //default timezone set to indian time $now = date("m/d/y G.i:s"); echo $now; ?>

Check for date functions in PHP

$sql = "
    SELECT columnname 
    FROM tablename 
    WHERE DATE(yourdatefieldname) >= DATE(NOW())";

write this in if else