int num = DateTime.Compare(DateTime.Now, DateTime.UtcNow);
if (num > 0)
{
    text3 = "+";
}
else
{
    text3 = "";
}
String errtime = "(GMT" + text3 + num.ToString() + ")";
-------------------------------
主要是DateTime.UtcNow 和"(GMT" + text3 + num.ToString() + ")"
在这里是什么做用

解决方案 »

  1.   

    string text3 = "";            int num = ((TimeSpan)(DateTime.Now - DateTime.UtcNow)).Hours;
                if (num > 0)
                {
                    text3 = "+";
                }
                else
                {
                    text3 = "";
                }
                 
                String errtime = "(GMT" + text3 + num.ToString() + ")";
                Response.Write(errtime);
      

  2.   

    分数不少,呵呵,可惜不知道怎么回答。
    这个GMT时间的格式,有这样的 情况 ;
    GMT
     GMT-12 
    GMT + 1
      

  3.   

    也许他的本意是计算时区,可惜错了, Compare 方法返回值说明:有符号数字,指示 t1 和 t2 的相对值。 小于零 , 当 t1 小于 t2。 
     
    零 ,  当 t1 等于 t2。 
     
    大于零, 当 t1 大于 t2。 
     
      

  4.   

    DateTime.UtcNow是DataTime考虑时区的一个属性,这段代码最终的目的应该是想按时区显示当前时间。
      

  5.   

    显示时间,并在前面以GMT的形式显示时区。不过它的写法是错误的,楼上 cpp2017(慕白兄) 已经给出正确代码了。