Create Timestamp Using PHP

Hello Guys Welcome to Coding Gurus Online Portal ...!

PHP provides several date time functions to perform required operations with temporal data. Now, we are going to see about PHP timestamp functions. Timestamp is the value represented as seconds calculated, since UNIX Epoch, January 1, 1970, and also called as UNIX timestamp.


In PHP, it includes several functions to work with timestamp. In this article, we are going to see about how the following list of timestamp related functionalities are obtained by using PHP date time functions.

These functionalities of PHP comes handy to keep track of your operations, own log of your events and actions in your wbesite. Timestamping helps you keep record of your activities and all you have to do is define a timestamp attribute in your database. The code is simple and clear. So go ahead and make your application even more organized.


php_timestamp

Getting Current Timestamp in PHP


We can get current timestamp value in three possible ways with the help of PHP core functions described here.


<?php
date_default_timezone_set('Asia/Calcutta');
$datetime =date("F j, Y, g:i a");
echo "Formatted date from timestamp:"
$datetime;
?>

Note:

The time zones should be defined in the function date_default_timezone(" Here ") ,we have specied Asia/Calcutta as our default time zone ,list of few time zones are defined below for further more zones please visit thie link here.



Asia/Aden Asia/Almaty Asia/Amman Asia/Anadyr  
Asia/Aqtobe Asia/Ashgabat Asia/Ashkhabad Asia/Baghdad  
Asia/Baku Asia/Bangkok Asia/Beirut Asia/Bishkek  
Asia/Calcutta Asia/Choibalsan Asia/Chongqing Asia/Chungking  
Asia/Dacca Asia/Damascus Asia/Dhaka Asia/Dili  
Asia/Dushanbe Asia/Gaza Asia/Harbin Asia/Hebron  
Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Istanbul  
Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka  
Asia/Kashgar Asia/Kathmandu Asia/Katmandu Asia/Khandyga  
Asia/Krasnoyarsk Asia/Kuala_Lumpur Asia/Kuching Asia/Kuwait  
Asia/Macau Asia/Magadan Asia/Makassar Asia/Manila  
Asia/Nicosia Asia/Novokuznetsk Asia/Novosibirsk Asia/Omsk  
Asia/Phnom_Penh Asia/Pontianak Asia/Pyongyang Asia/Qatar  
Asia/Rangoon Asia/Riyadh Asia/Saigon Asia/Sakhalin  
Asia/Seoul Asia/Shanghai Asia/Singapore Asia/Taipei  
Asia/Tbilisi Asia/Tehran Asia/Tel_Aviv Asia/Thimbu  
Asia/Tokyo Asia/Ujung_Pandang Asia/Ulaanbaatar Asia/Ulan_Bator  
Asia/Ust-Nera Asia/Vientiane Asia/Vladivostok Asia/Yakutsk  
Asia/Yekaterinburg