تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
فحص التاريغ
#1
هل يمكن فحص الوقت و التاريخ مثلآ عندى فورم فيها 3 Label الاولة تحصل على الوقت و التريغ من هذا الكود

كود :
   Public Shared Function GetNistTime() As DateTime
       Dim dateTime As DateTime = DateTime.MinValue

       Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://nist.time.gov/actualtime.cgi?lzbc=siqm9b"), HttpWebRequest)
       request.Method = "GET"
       request.Accept = "text/html, application/xhtml+xml, */*"
       request.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
       request.ContentType = "application/x-www-form-urlencoded"
       request.CachePolicy = New RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)
       'No caching
       Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
       If response.StatusCode = HttpStatusCode.OK Then
           Dim stream As New StreamReader(response.GetResponseStream())
           Dim html As String = stream.ReadToEnd()
           '<timestamp time=\"1395772696469995\" delay=\"1395772696469995\"/>
           Dim time As String = Regex.Match(html, "(?<=\btime="")[^""]*").Value

           Dim milliseconds As Double = Convert.ToInt64(time) / 1000.0

           dateTime = New DateTime(1970, 1, 1).AddMilliseconds(milliseconds).ToLocalTime()
       End If
       Return dateTime
   End Function

اما الثانية فيتم كتابة الوقت و التريخ

كود :
Label2.Text = "9/29/2016 11:20:20 AM"

ايد ان اعرف اذا كان Label1 اكبر من Label2

كود :
       If Label1.Text > Label2.Text Then
           Label3.Text = "Time Out"
       Else
           Label3.Text = "Time Running"
       End If

مشكلة هذا الكود انه لا يفرق بين PM و AM هل من حل ؟
الرد }}}
تم الشكر بواسطة:
#2
(30-09-16, 01:53 AM)HASAN6.0 كتب : استخدم صيغه 24
PHP كود :
Format(GetNistTime(), "yyyy/MM/dd HH:mm:ss"

شكرآ اخى جزاك الله خير
الرد }}}
تم الشكر بواسطة:


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم