By 05/02/2014 1 Comments

How to Process MySQL Timestamp in PHP

What is MySQL Timestamp?

  • It is a temporal data type
  • It holds the combination of date and time
  • It’s column format is YYYY-MM-DD HH:MM:SS
  • PHP uses UNIX timestamps for Date functionality
  • If you want to get timestamp value from database then you have to use “SELECT  UNIX_TIMESTAMP(your_db_field_name)

Code for process MySQL Timestamp in PHP.

<?php

$query = "select UNIX_TIMESTAMP(field_name) as mdate from table_name where 1=1"; // a sql query to db table for get the time_stamp

$records = mysql_query($query) or die(mysql_error()); // this function process sql query and assign to $records variable 

while($row = mysql_fetch_array($records)) // loop through and get the result of sql from database in the form of an array

{

echo $row;  // display result on webpage

}

?>






Posted in: PHP

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .