吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5123|回复: 5
收起左侧

[原创工具] C#语言线程获取时间戳转换时间(源代码+程序)

  [复制链接]
missjx137600 发表于 2015-11-13 21:02
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Timers;
using System.Windows.Forms;

namespace 线程获取时间戳转换时间
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string b = "";//时间戳返回值
        System.Timers.Timer timer = new System.Timers.Timer();//线程时间
        private delegate void weituo();//委托
        private void Form1_Load(object sender, EventArgs e)
        {
            timer.Elapsed += new ElapsedEventHandler(delegate {
                time();
            });
            timer.Interval = 1;
            timer.Start();

        }
        public void time()
        {
            WebClient a = new WebClient();
            a.Encoding = Encoding.GetEncoding("GB2312");
            Uri uri = new Uri("http://www.hko.gov.hk/cgi-bin/gts/time5a.pr");//获取时间戳
            b = Encoding.UTF8.GetString(a.DownloadData(uri));
            b = b.Replace("0=", "");
            double time = Convert.ToDouble(b);
            DateTime now = ConvertIntDateTime(time);
            if (label1.InvokeRequired)
            {
                weituo label = delegate {
                    label1.Text = now.ToString();
                };
                label1.Invoke(label);
            }
            

        }
        public static DateTime ConvertIntDateTime(double d)
        {
            System.DateTime time = System.DateTime.MinValue;
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            time = startTime.AddMilliseconds(d);
            return time;
        }//时间戳转换

    }
}

C#语言线程获取时间戳转换时间

源码下载地址: 线程获取时间戳转换时间.zip (51.74 KB, 下载次数: 30)

没CB的直接在上面复制即可,别忘记添加引用!!!


免费评分

参与人数 1热心值 +1 收起 理由
bigharvest + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

zgc2012 发表于 2015-11-13 21:35
还是易语言简单,俩个命令就可以了
痴心的叶子 发表于 2015-11-13 22:12
liuchan 发表于 2015-11-16 08:31
xiaotaozi101 发表于 2015-12-17 20:00
不错好东东
撒旦asd 发表于 2015-12-19 11:38
学习一下
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 提醒:禁止复制他人回复等『恶意灌水』行为,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-3-28 21:55

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表