Comparing current datetime with datetime from database without refreshing page

I want to make a simple reminder which displays something when the current date and time matches an entry in a database, without refreshing the page.

I have two entries in my database in a table called date:

  • date (stores reminder date) which is type DATE and
  • time (stores reminder time) which has type TIME.

The page reminder.php fetches the date and time stored in database and converts it into Timestamp.

This page also converts the current date and time into Timestamp using strtotime("now").

It displays both date and time when both values match by continuously refreshing the page every second.

I want to compare both values without refreshing the reminder.php page.


require_once 'php/database.php';
$current = strtotime('now');
$stmt = $db->query("SELECT * FROM date");
$row = $stmt->fetchall(PDO::FETCH_ASSOC);
foreach ($row as $key) {
    $dateTime = $key['date'] . $key['time'];
    $dateTime  = strtotime($dateTime);


if ($dateTime == $current) {
    echo  "both date and time are same";
else {

    echo "both date and time are not same";



If I understands right then you need to check date from the database and current date without refreshing the page use this code , HTML Part :

<button id="data_pass" name="btn" >BUTTON</button>

JQuERy :

 $(document).ready(function() {
$("#data_pass").click(function() {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {

if(mm<10) {

today = yyyy+'-'+mm+'-'+dd;

url  : 'test.php',
type : 'post',
data : {"today":today},
success : function(data) {
error : function(data) {



PHP Part :


   class date_check extends db_connection { 
   function dates() {
    $con    = $this->db_con();
    $sel    = $con->prepare("select * from dates");
    $exe    = $sel->execute();
    $dates  = $_POST['today'];
    foreach ($sel as $select) {
        if ($select['date_i'] == $dates) {
            echo "Happy BirthDay";  


 $obj   = new date_check;

It's only for checking the date. hope it will help you

Need Your Help

how to make the actionbar transparent

android android-actionbar

i am learning actionbar and created an actionbar with tabs .the following image shows the view