php get now date code example

Example 1: php get current year

$currentYear=date("Y");//2019

Example 2: php get current date and time

$today = date("F j, Y, g:i a");   // October 30, 2019, 10:42 pm
$today = date("D M j G:i:s T Y"); // Wed Oct 30 22:42:18 UTC 2019
$today = date("Y-m-d H:i:s");     // 2019-10-30 22:42:18(MySQL DATETIME format)

Example 3: date now php

date('Y-m-d H:i:s')

Example 4: php get day from date

$timestamp = strtotime('2009-10-22');

$day = date('D', $timestamp);
var_dump($day);

Example 5: php format date

<?php
  // To change the format of an existing date
  $old_date_format = "20/03/1999";
  $new_data_format = date("Y-m-d H:i:s", strtotime($old_date_format));

Example 6: date now php

date("Y-m-d H:i:s");

Tags:

Php Example