Chrome Extension

Date time in PHP

<?php
    //If we assume year - 2020, month - March, date - 10
    $format_date = date("Y-m-d H:i:s");                   // 2020-03-10 17:16:18 (MySQL DATETIME format)
    $format_date = date("F j, Y, g:i a");                 // March 10, 2020, 5:16 pm
    $format_date = date("m.d.y");                         // 03.10.20
    $format_date = date("j, n, Y");                       // 10, 3, 2020
    $format_date = date("Ymd");                           // 20200310
    $format_date = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-20, 1631 1618 6 Satpm01
    $format_date = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.
    $format_date = date("D M j G:i:s T Y");               // Sat Mar 10 17:16:18 MST 2001
    $format_date = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:18 m is month
    $format_date = date("H:i:s");                         // 17:16:18
?>
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

date() function in PHP is used to get the current date and format it according to your requirements. The format string is a required parameter in date() function which returns you the formatted date that you pass in that function.

Was this helpful?
0 Comments