PHP Date and Time Formatting Functions

PHP Date and Time Formatting Functions

In this Post We Will Explain About is PHP Date and Time Formatting Functions With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to PHP Date and Time FunctionExample

In this post we will show you Best way to implement Formatting Dates and Tiems in PHP, hear for Getting the Time Stamp with time using PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

You can download source code and Demo from below link.




Also Read :   Registration Form Validation using Ajax in Codeigniter

declaration of date

Returns a simple string formatted simple using PHP according to the given some format string using the given integer with php date timestamp or the get current time if no simple timestamp is given. as well as In other words, means syntex of the $timestamp is optional and defaults to default the value of time() Like as a Date and time formatting with PHP.

string date ( string $format [, int $timestamp ] )

Example : Date and Time Formatting with PHP
2018-02-09 16:45:58
Feb 09 18 4:45:58 pm

Date formatting with PHP

Not many people can simple read this clearly any date error without any problems. This is simple the current server time.Please all the formats check Now see this:

Also Read :   Facebook PHP SDK V5 integration with Codeigniter 3

echo date("d-m-y", time());     	// 09-02-18
echo date("D j/n/Y", time());     	// Thu 7/2/2018
echo date("jS of F Y", time());     // 9th of February 2018
echo date("d M y", time());     	//09 Feb 18
echo date("l jS of F", time());     // Thursday 9th of February

Time formatting with PHP

echo date("G:i:s", time());      //16:30:58
echo date("H:i:s", time());    	 //16:30:58
echo date("g:i a.", time());     //4:30 pm.
echo date("h:i A.", time());     //04:30 PM.

Date and time formatting with PHP

echo date("l jS of F g:i A.", time());    // Thursday 9th of February 4:30 PM.
echo date("D M j G:i:s T Y", time());     // Thu Feb 9 16:30:58 EET 2018

PHP Date Formatting Custom Functions

<?php  
$start = "30-08-2017 07:08 PM";
$end = "30-08-2017 07:08 PM";
echo "<pre>";
print_r(createRange($start, $end, $format = 'd-m-Y H:i:s'));
echo "</pre>";

function createRange($start, $end, $format = 'd-m-Y H:i:s') {
    $start  = new DateTime($start);
    $end    = new DateTime($end);	
    $invert = $start > $end;

    $dates = array();
    $dates[] = $start->format($format);
    while ($start != $end) {
        $start->modify(($invert ? '-' : '+') . '1 day');
        $dates[] = $start->format($format);
    }
    return $dates;
}
?>

You can download source code and Demo from below link.





Example

Also Read :   CodeIgniter Simple User Registration and Login System

I hope you have Got What is Date formatting with date() function for PHP Code Example And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.