dongtang8678 2016-01-11 18:32
浏览 23
已采纳

使用php格式化infusionsoft返回日期

i worked on the code to get subscription start date & end date from the infusionsoft and it return in this format

Start date=20151217T00:00:00

EndDate=20161217T00:00:00

how i can format to YYYY/MM/DD H:M:S ?

and what the 'T' stands for

  • 写回答

4条回答 默认 最新

  • dragon4808 2016-01-11 18:55
    关注

    The T, according to the the ISO 8601 standard, is the delimiter between the date and time parts.

    See: ISO 8601 standard, Wikipedia

    There are two functions you could use:

    1. strtotime(date_time_string)

      Converts a date/time string into a timestamp.

    2. date(format, timestamp)

      Formats a timestamp into a string according to "format".

    The example code…

    $so_string = '20151217T00:00:00';
    $eo_string = '20161217T00:00:00';
    
    $sd_stamp = strtotime($so_string);
    $ed_stamp = strtotime($eo_string);
    
    $f_datetime ='Y/m/d H:i:s';
    
    echo 'Start date<br />';
    echo '&nbsp;&nbsp;&nbsp;original: '  . $so_string . '<br />';
    echo '&nbsp;&nbsp;&nbsp;timestamp: ' . $sd_stamp . '<br />';
    echo '&nbsp;&nbsp;&nbsp;formatted: ' . date($f_datetime,$sd_stamp) . '<br /><br />';
    echo 'End date<br />';
    echo '&nbsp;&nbsp;&nbsp;original: '  . $eo_string . '<br />';
    echo '&nbsp;&nbsp;&nbsp;timestamp: ' . $ed_stamp. '<br />';
    echo '&nbsp;&nbsp;&nbsp;formatted: ' . date($f_datetime,$ed_stamp) . '<br />';
    

    …will produce this output:

    Start date
       original: 20151217T00:00:00
       timestamp: 1450306800
       formatted: 2015/12/17 00:00:00
    
    End date
       original: 20161217T00:00:00
       timestamp: 1481929200
       formatted: 2016/12/17 00:00:00
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义
  • ¥15 嵌入式--定时器使用