Computer Learning Zone CLZ Access Excel Word Windows

What does God need with a starship?

-James T. Kirk
 
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
 
Home > Code Vault > Access VBA > Get UTC
Get UTC from Web API
By Richard Rost   Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   3 years ago

This code will return the current UTC time from the WorldTimeAPI.org web server.

Public Function GetUTCTime() As Date

    Dim XMLHTTP As Object
    Dim ResponseText As String
    Dim MyURL As String
    Dim L As Long, S As String
    
    MyURL = "http://worldtimeapi.org/api/ip.txt"
    Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")
    XMLHTTP.Open "GET", MyURL, False
    XMLHTTP.send
    ResponseText = XMLHTTP.ResponseText
    ResponseText = Replace(ResponseText, Chr(10), vbNewLine)
    Set XMLHTTP = Nothing
    
    S = ResponseText
    L = InStr(S, "utc_datetime:")
    S = Right(S, Len(S) - L + 1)
    S = Left(S, 33)
    S = Mid(S, 20, 2) & "/" & Mid(S, 23, 2) & "/" & Mid(S, 15, 4) & " " & Right(S, 8)

    GetUTCTime = CDate(S)
    
End Function

This code will Restore Down the Access Application Window

MyUTCTime = GetUTCTime()

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Get UTC from Web API
Get notifications when this page is updated
 
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
amicron@gmail.com
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Copyright 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 1/28/2023 3:39:31 AM.
Keywords: code vault access getutctime utc time web api worldtimeapi.org  PermaLink  Get UTC from Web API