Tuesday, 31 March 2020

Python Django Useful Commands

Start python development server:
python manage.py runserver

Start python development server with custom port
python manage.py runserver 8080

How to fetch timestamp in PHP

Below is the method to fetch the timestamp in PHP according to your timezone:

//////////////////////////////////////////////////////
/////////////PHP 5.2 and older version////////////////
//////////////////////////////////////////////////////
date_default_timezone_set('Australia/Melbourne');
echo $today = date("Y-m-d H:i:s"); 

//////////////////////////////////////////////////////
//////////////////////PHP 5.2 above///////////////////
//////////////////////////////////////////////////////
use \Datetime;
$now = new DateTime();
$now->setTimezone(new DateTimeZone('Asia/Kolkata'));
echo $now->format('Y-m-d H:i:s');