AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
HTML Tutorial

PHP date () function formats


<< Previous Page
PHP GET and POST
Next Page >>
PHP Login


Definition and Usage
PHP date() function formats a local date and time, and returns the formatted date string.

PHP Date / Time Functions - how to create? - example


Syntax of PHP date:
date(format,timestamp);

Example 1: date(format,timestamp);
<?php
// Set the default time zone. Available starting with PHP 5.1
date_default_timezone_set('UTC');

// Show something like this: Monday
echo date("l");

// Show something like this: Monday 8th of August 2005 03:12:46 PM
echo date('l jS \of F Y h:i:s A');

// View: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));

/* using constants in format parameter */
// Show something like this: Wed, 25 Sep 2013 15:28:57 -0700

echo date(DATE_RFC2822);

// Show something like this: 2000-07-01T00: 00: 00 + 00: 00
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
?>
Note: 

Formatting Data () - How to create

Some examples of data formatting (). You need to escape the extra characters, because those with special meaning will produce unwanted results, and the other characters can be of special significance in future versions of PHP. Be sure to use single quotes to prevent characters from \ n becoming a newline.

Example 2:
<?php
// Assume that today is March 10th, 2019 5:16:18 pm
// and we are in the time zone Mountain Standard Time (MST)


$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (formatul MySQL DATETIME)
?>

The PHP cod above will display this result -
Note: 

<< Previous Page
PHP GET and POST
Next Page >>
PHP Login




PHP Date, Time Functions, How to create php date
PHP Date / Time Functions - how to create? - example - php tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Home
PHP Introduction
PHP Install
PHP Syntax
PHP Variables
PHP Echo and Print
PHP Data Types
PHP String Function
PHP Constants
PHP Operator Types
PHP If Else and Elseif
PHP Switch
PHP While Loops
PHP Loop For Do Foreach
PHP Array
Convert Array to String
PHP Function
PHP GET and POST
PHP Date/Time Functions
PHP Login
PHP Delete Element
PHP eregi_replace()
PHP mysql_query()
PHP Errors to Display
PHP Loop For Do Foreach

PHP forms
PHP Form Example
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.