【问题标题】:How to convert 26-Feb-2013 type date fomat into 26-02-2013 format using php如何使用 php 将 26-Feb-2013 类型的日期格式转换为 26-02-2013 格式
【发布时间】:2013-02-04 03:29:07
【问题描述】:

我想使用 php 将 26-Feb-2013 类型的日期格式转换为 26-02-2013 格式 我可以按照以下方式长期做到这一点

$date='26-Feb-2013';
$datew=explode('-',$date);
$mounth=$datew[1];
if($mounth=='Jan'){
$mounth=='Jan'

}
elseif($mounth=='feb'){
$mounth=='Feb'

}

再次使用 implode 函数转换 26-02-2013 格式 但我想知道任何简单的方法来做到这一点 有什么办法吗?

【问题讨论】:

  • this earlier question查看直接相关的对话
  • 但问题是我不知道将 2 月转换为 2 月
  • @master3w 你不必这样做。 PHP 内置了这种东西。
  • 我之前的链接和建议的功能会让您找到答案...您可以通过这种方式了解更多信息!

标签: php


【解决方案1】:
$date='26-Feb-2013';
echo date("d-m-Y", strtotime($date)); // prints 26-02-2013

【讨论】:

    【解决方案2】:

    试试这个:

       $date='26-Feb-2013';
       $datew= date('d-m-Y',strtotime($date));
    

    修正了抱歉应该在提交前测试

    【讨论】:

    • 警告:date_format() 期望参数 1 为 DateTime,字符串在 F:\project\wamp\www\oo\date.php 第 3 行错误 com 中给出
    【解决方案3】:

    试试这个

     $date='26-Feb-2013';
     echo $datew = date('d-m-Y',strtotime($date));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 1970-01-01
      • 2015-04-05
      • 1970-01-01
      • 2011-10-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多