I have only this field of php
statment, and the output of this field is: August 11 2016
but how can I make this 11 08 2016
?
<?php the_time(get_option( 'date_format' )); ?>
Are you referring to the WordPress function the_time()
found here:
https://codex.wordpress.org/Function_Reference/the_time
If so, inside the parenthesis you can specify the format as below:
<?php the_time('d m Y'); ?>
If you would like a list of the formatting options for PHP dates check the below manual page:
the_time() method of wordpress accepts argument of the format you want to print the time. So update the code like this to print it in desired format.
<?php the_time('d m Y'); ?>
You can use createFromFormat to create the DateTime object from string according to the format, and then use format method to print it in desired format.
Your code should look something like this,
<?php
$date_string= "August 11 2016";
$date = DateTime::createFromFormat('F d Y',$date_string);
echo $date->format("d m Y");
Demo: https://eval.in/621469
Where F d Y
is the input date format and d m Y
is the output date format.
createFromFormat returns new DateTime object formatted according to the specified format passed as first argument.
Here is a simple solution:
echo date('d m Y', strtotime("August 11 2016"));
Unix time-stamp
using strtotime