dsij89625 2012-10-16 13:14
浏览 69
已采纳

php从epoch ms获取日期

I have a field in ms from epoch, like 1350393140000. I need to, in PhP, get this field as a datetime, change the time portion of it to 7AM (UTC time) and convert it back to ms from epoch. How can I do this?

  • 写回答

2条回答 默认 最新

  • dsqtl335227 2012-10-16 13:16
    关注
    $input = 1350393140000;
    
    $dt = new DateTime('@' . floor($input / 1000));
    $dt->setTimeZone(new DateTimeZone('UTC'));
    $dt->modify('07:00');
    
    $output = $dt->format('U') * 1000;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥50 comsol稳态求解器 找不到解,奇异矩阵有1个空方程返回的解不收敛。没有返回所有参数步长;pid控制
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信