donglangtun1850 2013-03-28 11:36
浏览 20

以UTC格式转换时间

I have following code:

$start_time="6:00 PM";

$end_time="10:00 PM";

The above time are according the countries timezone i.e (Asia/Colombo, Asia/Adelaide...etc)

And I want to perform the following calcuation:

date_default_timezone_set("UTC");
$system_time = date('g:i A'); //Getting the system time according to the UTC timezone

    $time_left_for_discussion = $start_time - $system_time;

    if ($system_day < $day) {
        return "Upcoming";
    } else if ($system_day == $day) {
        if ($time_left_for_discussion <= 0 && $system_time <= $end_time) {
            return "Live";
        } else {
            return "NA";
        }
    } else {
        return "NA";
    }

Here the $system_time is according the UTC timezone. Now I want calculation for $time_left_for_discussion so for that I need need to convert $start_time and $end_time in UTC format for correct calucation.

Hope you got my point.

  • 写回答

2条回答 默认 最新

  • doulu7258 2013-03-28 11:38
    关注

    Try the dateTime class.

    $date = new DateTime("2010-07-05T06:00:00Z");
    $date->setTimeZone(new DateTimeZone("UTC"));
    
    评论

报告相同问题?

悬赏问题

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