How to Convert String Date to Date Format in PHP?
In this post we will give you information about How to Convert String Date to Date Format in PHP?. Hear we will give you detail about How to Convert String Date to Date Format in PHP?And how to use it also give you demo for it if it is necessary.
When ever you need to convert string date to date formate like m/d/Y, Y-m-d, d-m-Y etc in php. we can easily convert string date specific date formate in php. we will use date() for converting string date to formate. we can also set timezone before convert string date to date in php example.
In this example i will give you very simple way to convert php string date to date formate. i gave you two example to understand how you will php string date format conversion. Also added output of that php example.
So, let’s see both example. you can understand how it works.
Example:
<?php
$myStringDate = "1564079400";
date_default_timezone_set('Asia/Kolkata');
$newDateFormat = date('m/d/Y', $myStringDate);
print_r($newDateFormat);
?>
Output:
07/26/2019
Example 2:
<?php
$myStringDate = strtotime('26-07-2019');
$newDateFormat = date('m/d/Y',$myStringDate);
print_r($newDateFormat);
?>
Output:
07/26/2019
I hope it can help you…
Hope this code and post will helped you for implement How to Convert String Date to Date Format in PHP?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs