dqmdlo9674 2013-03-14 10:40 采纳率: 100%
浏览 192
已采纳

如何使用日期回应默认的date 0000-00-00(“F j,Y,”); 如果日期没有更新?

in my database default value of date is set to not null 0000-00-00and i use the date format date("F j, Y, "); to print out the date.

if i echo the date using strtotime function in the following way,

echo date("F j, Y", strtotime($row_schedule['meeting_date']));

it returns November 30, -0001 based on the set default date 0000-00-00

whereas if i update the default value of date from 0000-00-00 to a real time date like, 2013-02-28 it gives the appropriate output as it should be like,

February 28, 2013

my question is how can i print default date as 0000-00-00 but not November 30, -0001 using my current output method?

  • 写回答

4条回答 默认 最新

  • dongzhitao4839 2013-03-14 10:46
    关注

    You can always write your own function

    function myDate($time){
      if($time == '0000-00-00')
         return $time;
      return date("F j, Y", strtotime($time));
    }
    

    and then just echo myDate($row_schedule['meeting_date']);.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测