Friday, August 1, 2008

How to get the date from MySql TIMESTAMP column using php

In mysql you can use a TIMESTAMP type to store both date and time in a table column in this format YYYY-MM-DD HH:MM:SS
Sometimes you need to get only the date part from the TIMESTAMP.
You can use mysql date() function to do this


<?php

$today = date("Y-m-d"); //todays date

$query = "select * from tbl where DATE(c_timstp) = $today";

$result = mysql_query($query);

?>



Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

3 comments:

  1. Weird, you posted this 3 years ago now two people are both thanking you almost within a couple of days of each other!

    Anyway, thanks I was just looking how to do this!

    ReplyDelete