dongzi9196 2017-09-08 13:00
浏览 455
已采纳

按小时和分钟分割时间

I have a db table that contains time in the following format hhmm.

I need to split hour from minutes. I think I can use something like

substr($time, 0, 2);

It works well when my time looks like: 1430, however I'm not sure what to do when I have something like 710.

  • 写回答

1条回答 默认 最新

  • dongzhuo1880 2017-09-08 13:04
    关注

    You can use a negative offset instead, that counts backwards from the end of the string

    substr($time, 0, -2); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?