///
/// 获取标准北京时间
///
///
public static DateTime GetStandardTime()
{
try
{
System.Net.WebClient webclient = new System.Net.WebClient();
string strhtml = webclient.DownloadString("http://open.baidu.com/special/time/");
int timeindex = strhtml.IndexOf("window.baidu_time(") + 18;
string strtime = strhtml.Substring(timeindex, 13);
long longtime = Convert.ToInt64(strtime) / 1000;
DateTime oritime = Convert.ToDateTime("1970-1-1 0:0:0");
oritime = oritime.AddSeconds(longtime).AddHours(8);//8为时区
return oritime;
}
catch (WebException webex)
{
throw new WebException(webex.Message);
//return DateTime.Now;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
//return DateTime.Now;
}
}