donglu1472 2015-06-16 15:05
浏览 43

strtotime在php之前显示一个日期

I've a date in the format dd/mm/YYYY. Eg: 25/06/2015. I want convert it to timestamp. I've added the following code to implement this;

$timestamp = strtotime( str_replace( '/', '-', '25/06/2015' ) );

It creates timestamp, but when I convert that timestamp I can see that it is one day before. When I execute the above code, I got the timestamp value "1435183200". When I convert this I got the previous date "24/06/2015".

If anybody knows the solution to fix this, please help.

  • 写回答

1条回答 默认 最新

  • duai0935 2015-06-16 15:12
    关注

    I think you have the default timezone configured in PHP. Try switching your timezone. Use:

    date_default_timezone_set('your_timezone_here');
    

    For a list of supported timezones, go to http://php.net/manual/en/timezones.php

    评论

报告相同问题?

悬赏问题

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