Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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));
Comment

php date format

$originalDate = "2017-03-08";
$newDate = date("d/m/Y", strtotime($originalDate));
Comment

php all date formats

<?php
echo date("F j, Y, g:i a")."<br>";               // March 10, 2001, 5:16 pm
echo date("m.d.y")."<br>";                       // 03.10.01
echo date("j, n, Y")."<br>";                     // 10, 3, 2001
echo date("Ymd")."<br>";                         // 20010310
echo date('h-i-s, j-m-y, it is w Day')."<br>";   // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
echo date('i	 is 	he jS day.')."<br>"; // it is the 10th day.
echo date("D M j G:i:s T Y")."<br>";             // Sat Mar 10 17:16:18 MST 2001
echo date('H:m:s m is mo
	h')."<br>";   // 17:03:18 m is month
echo date("H:i:s")."<br>";                       // 17:16:18
echo date("Y-m-d H:i:s")."<br>";                 // 2001-03-10 17:16:18 (the MySQL DATETIME format)
Comment

Format and show date PHP

<?php echo date("h:i A d/m/Y", strtotime($past_event->added_date)); ?>
Comment

date formate in php

date("D M j G:i:s T Y")."<br>";             // Sat Mar 22 17:16:18 MST 2001
date('H:m:s m is mo
	h')."<br>";   // 18:03:18 m is month
date("H:i:s")."<br>";                       // 18:16:18
date("Y-m-d H:i:s")."<br>";                 // 2022-03-11 18:16:18 (MySQL DATETIME format)
date("j F, Y, g:i a")."<br>";               // 11 March, 2022, 6:16 pm
date("m.d.y")."<br>";                       // 03.11.01
date("j, n, Y")."<br>";                     // 11, 3, 2001
date("Ymd")."<br>";                         // 20010310
date('h-i-s, j-m-y, it is w Day')."<br>";   // 02-12-18, 10-03-01, 1631 1618 6 Satpm01
date('i	 is 	he jS day.')."<br>"; // it is the 15th day.
Comment

php format date

<?php
  	$date = '05/05/2021';
	echo DateTime::createFromFormat("d/m/Y", $date)->format('Y-m-d');
	//2021-05-05
Comment

php date from format

<?php
$date = DateTime::createFromFormat('j-M-Y', '15-Feb-2009');
echo $date->format('Y-m-d');
?>
Comment

format date in php

$myDateTime = DateTime::createFromFormat('Y-m-d', $dateString);
$newDateString = $myDateTime->format('d-m-Y');
Comment

date format in php

date('m/d/Y h:i:s a',strtotime($val['EventDateTime']));
Comment

format a date sting php

# From a date Object:
date_format ( DateTimeInterface $object , string $format )

# From the current time
$dateTime = new DateTime(); 
// or pass a string or int ->`DateTime($date_time)`
$dateTime->format('y-j-d H:i:s T'); #print ex: 21-2-02 16:00:01 PST

# Or a quick one-liner:
date('g:i A m-d-Y', strtotime($date_time)); #print ex: 2:00 PM 02-02-2021
Comment

php date format

<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
//
$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	 is 	he jS day.');   // 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 is mo
	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 (the MySQL DATETIME format)
?>
Comment

date time format php

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
Comment

PHP Date time formatting


a - "am" or "pm"
A - "AM" or "PM"
d - day of the month, 2 digits with leading zeros; "01" to "31"
D - day of the week as text, 3 letters; "Mon"
F - month as text, full name; "January"
h - hour, 12-hour format; "01" to "12"
H - hour, 24-hour format; "00" to "23"
g - hour, 12-hour format without leading zeros; "1" to "12"
G - hour, 24-hour format without leading zeros; "0" to "23"
i - minutes; "00" to "59"
j - day of the month as a number without leading zeros; "1" to "31"
l (lowercase L) - day of the week as text, full name; "Monday"
L - boolean for if it is a leap year; "0" or "1"
m - month as a number; "01" to "12"
n - month as a number without leading zeros; "1" to "12"
M - month as text, 3 letters; "Jan"
s - seconds; "00" to "59"
S - English ordinal suffix as text, 2 characters; "th", "nd"
t - number of days in the given month; "28" to "31"
U - seconds since the epoch
w - day of the week as a number; "0" (Sunday) to "6" (Saturday)
Y - year, 4 digits; "1999"
y - year, 2 digits; "99"
z - day of the year; "0" to "365"
Z - timezone offset in seconds ("-43200" to "43200")
Comment

php date format

PHP Date Formats
Comment

PREVIOUS NEXT
Code Example
Php :: php insert character into string 
Php :: object values to array php 
Php :: test curl php 
Php :: woocommerce get all subscriptions by user id 
Php :: Laravel 9 Clear Cache of Route, View, Config, Event Commands 
Php :: php routing 
Php :: php increment letter 
Php :: foreignid in laravel 
Php :: laravel custom 404 blade 
Php :: laravel change column 
Php :: php create zip from folder 
Php :: laravel where first 
Php :: valet laravel 
Php :: eloquent get distinct 
Php :: how to check laravel version in cmd 
Php :: multiply a string php 
Php :: javascript php loop 
Php :: if browser url is having query string after domain name in it check using php 
Php :: mysql_fetch_array php 
Php :: php get class name without namespace from string 
Php :: joomla cache programing clear 
Php :: php convert to lowercase 
Php :: mysqli loop 
Php :: laravel check if model relation exists 
Php :: php add 1 day to current date 
Php :: php cli display errors 
Php :: php remove stop words from string 
Php :: install php 8 ubuntu 
Php :: get values from text file php 
Php :: merge two query results in laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =