I want to make my date format in Month-Date-Year
. Current format is Year-Month-Date
. How do I do that in PHP?
我想在一个月的时间里制定我的日期格式。现在的格式是Year-Month-Date。在PHP中怎么做呢?
9 个解决方案
#1
4
$date = "08/01/2013";
$your_date = date("m-d-y", strtotime($date));
I hope my answer is useful :)
我希望我的答案是有用的:)
#2
5
$originalDate = "2013-01-08";
$newDate = date("m-d-Y", strtotime($originalDate));
#3
3
You can use strtotime() to parse the date. This literally took me one Google Search to figure this out.
可以使用strtotime()来解析日期。我用谷歌搜索了一下。
$given = "2013-01-08";
$parseit = date("m-d-Y", strtotime($given));
And then you can echo it something like this:
然后你可以这样回应:
echo $parseit;
#4
2
echo date('m-d-Y', time());
回声日期(“m-d-Y”、时间());
For more information see PHP's date documentation.
有关更多信息,请参阅PHP的日期文档。
#5
1
Try this.
试试这个。
date('m-d-y', strtotime('2012-12-31'));
or
或
$d = new DateTime('2012-12-31');
echo $d->format('m-d-y');
#6
0
You can use strtotime()
to get your string back into a time variable. Then use date()
to format the time to your required format.
可以使用strtotime()将字符串返回到时间变量中。然后使用date()将时间格式化为所需的格式。
#7
0
Just use
只使用
date("m-d-Y");
This will output your in Month-Date-Year
.
这将在一个月的时间内输出您的数据。
#8
0
$date = date("m-d-Y",strtotime($yourdate));
#9
0
Refer to these two functions:
请参考这两个功能:
DateTime::createFromFormat
- DateTime:createFromFormat
DateTime::format
- DateTime:格式
For example (you need to update format)
例如(需要更新格式)
$date = DateTime::createFromFormat('j-M-Y', '15-Feb-2009');
echo $date->format('Y-m-d');
#1
4
$date = "08/01/2013";
$your_date = date("m-d-y", strtotime($date));
I hope my answer is useful :)
我希望我的答案是有用的:)
#2
5
$originalDate = "2013-01-08";
$newDate = date("m-d-Y", strtotime($originalDate));
#3
3
You can use strtotime() to parse the date. This literally took me one Google Search to figure this out.
可以使用strtotime()来解析日期。我用谷歌搜索了一下。
$given = "2013-01-08";
$parseit = date("m-d-Y", strtotime($given));
And then you can echo it something like this:
然后你可以这样回应:
echo $parseit;
#4
2
echo date('m-d-Y', time());
回声日期(“m-d-Y”、时间());
For more information see PHP's date documentation.
有关更多信息,请参阅PHP的日期文档。
#5
1
Try this.
试试这个。
date('m-d-y', strtotime('2012-12-31'));
or
或
$d = new DateTime('2012-12-31');
echo $d->format('m-d-y');
#6
0
You can use strtotime()
to get your string back into a time variable. Then use date()
to format the time to your required format.
可以使用strtotime()将字符串返回到时间变量中。然后使用date()将时间格式化为所需的格式。
#7
0
Just use
只使用
date("m-d-Y");
This will output your in Month-Date-Year
.
这将在一个月的时间内输出您的数据。
#8
0
$date = date("m-d-Y",strtotime($yourdate));
#9
0
Refer to these two functions:
请参考这两个功能:
DateTime::createFromFormat
- DateTime:createFromFormat
DateTime::format
- DateTime:格式
For example (you need to update format)
例如(需要更新格式)
$date = DateTime::createFromFormat('j-M-Y', '15-Feb-2009');
echo $date->format('Y-m-d');