Computer Learning Zone CLZ Access Excel Word Windows

A good education is a foundation for a better future.

-Elizabeth Warren
 
Home   Courses   Seminars   Templates   Help   TechHelp   Forums   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   9 months 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 right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.
 
Subscribe
 
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
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
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: code vault access getutctime utc time web api worldtimeapi.org  PermaLink