Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:24:18+00:00 2026-05-23T14:24:18+00:00

I got stuck on this problem: I need to get time and date from

  • 0

I got stuck on this problem: I need to get time and date from page presnycas.eu (to sync). Date is fine, but I cannot get the time. The problem is that when I call IdHTTP.Get(..) method, as a result I get the HTML of the page, but the time is missing. Like this:

<div class="boxik"> 
<table style="text-align: left; width: 700px; height: 116px;" border="0" cellpadding="2" cellspacing="0"> 
  <tbody> 
    <tr> 
      <td style="width: 400px;" colspan="1" rowspan="5"> 
            <div class="hodinyhlavni"> 

            <span id="servertime"></span> 
              // This is where the time should be - when viewed with 
              // developer tools in Chrome, it does show the time
              // (picture here http://img684.imageshack.us/img684/166/pagem.png)
            </div> 
      </td> 
      <td style="width: 0px;"> &nbsp;      
           07.07.2011
      </td> 

Now I am using an awkward approach – I load a TWebBrowser and then call

Time:=StrToTime(WebBrowser1.OleObject.Document.GetElementByID('servertime').innerhtml);

but well, it’s rather slow and I would rather not use the TWebBrowser at all.

So, how can I get the innerhtml of an element with a call of function?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:24:19+00:00Added an answer on May 23, 2026 at 2:24 pm

    The most important part of this answer would be “you need to understand HTML and JavaScript and figure out how the site works”. Open the web site, right-click and do “Show Source”. You’ll notice this at the top:

    <script type="text/javascript">var currenttime = 'July 07, 2011 11:51:14'</script>
    

    That looks like the time, and in my case, the time is correct but not adjusted to MY time zone. You can easily grab the plain HTML using Indy, and apparently that’s enough. This quick code sample shows you how to grab the HTML and parse the date and time using a little piece of RegEx. If you’re on Delphi XE, you’ll have to replace the TPerlRegEx class name and the PerlRegEx unit name to whatever XE wants. If you’re on older Delphi, that’s no excuse to NOT use RegEx! Download TPerlRegEx, it’s free and compatible with the XE stuff.

    program Project29;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, IdHTTP, PerlRegEx, SysConst;
    
    function ExtractDayTime: TDateTime;
    var H: TIdHTTP;
        Response: string;
        RegEx: TPerlRegEx;
    
        s: string;
    
        Month, Year, Day, Hour, Minute, Second: Word;
    begin
      H := TIdHttp.Create(Nil);
      try
        Response := H.Get('http://presnycas.eu/');
        RegEx := TPerlRegEx.Create;
        try
          RegEx.RegEx := 'var\ currenttime\ \=\ \''(\w+)\ (\d{1,2})\,\ (\d{4})\ (\d{1,2})\:(\d{1,2})\:(\d{1,2})\''';
          RegEx.Subject := Response;
          if RegEx.Match then
            begin
    
              // Translate month
              s := RegEx.Groups[1];
              if s = SShortMonthNameJan then Month := 1
    
              else if s = SShortMonthNameFeb then Month := 2
              else if s = SShortMonthNameMar then Month := 3
              else if s = SShortMonthNameApr then Month := 4
              else if s = SShortMonthNameMay then Month := 5
              else if s = SShortMonthNameJun then Month := 6
              else if s = SShortMonthNameJul then Month := 7
              else if s = SShortMonthNameAug then Month := 8
              else if s = SShortMonthNameSep then Month := 9
              else if s = SShortMonthNameOct then Month := 10
              else if s = SShortMonthNameNov then Month := 11
              else if s = SShortMonthNameDec then Month := 12
    
              else if s = SLongMonthNameJan then Month := 1
              else if s = SLongMonthNameFeb then Month := 2
              else if s = SLongMonthNameMar then Month := 3
              else if s = SLongMonthNameApr then Month := 4
              else if s = SLongMonthNameMay then Month := 5
              else if s = SLongMonthNameJun then Month := 6
              else if s = SLongMonthNameJul then Month := 7
              else if s = SLongMonthNameAug then Month := 8
              else if s = SLongMonthNameSep then Month := 9
              else if s = SLongMonthNameOct then Month := 10
              else if s = SLongMonthNameNov then Month := 11
              else if s = SLongMonthNameDec then Month := 12
    
              else
                raise Exception.CreateFmt('Don''t know what month is: %s', [s]);
    
              // Day, Year, Hour, Minute, Second
              Day := StrToInt(RegEx.Groups[2]);
              Year := StrToInt(RegEx.Groups[3]);
              Hour := StrToInt(RegEx.Groups[4]);
              Minute := StrToInt(RegEx.Groups[5]);
              Second := StrToInt(RegEx.Groups[6]);
    
              Result := EncodeDate(Year, Month, Day) + EncodeTime(Hour, Minute, Second, 0);
    
            end
          else
            raise Exception.Create('Can''t get time!');
        finally RegEx.Free;
        end;
      finally H.Free;
      end;
    end;
    
    begin
      WriteLn(DateTimeToStr(ExtractDayTime));
      ReadLn;
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i find regex kinda confusing so i got stuck with this problem: i need
I got stuck in this problem for an hour. I am thinking this is
Im stuck on this httpWebRequest problem. I need to send XML to a website.
I got stuck with a performance problem while writing my program and I need
I'm stuck with this pretty silly thing; I got a textfile like this; Hello::140.0::Bye
I've got stuck in a problem with gflags when trying to find some memory
I am working on a problem and got stuck at a wall I have
I need to sort the results I get back from apache solr based on
I was given good direction to solve a problem today from here but I
I'm stuck on the following problem and would like to know if you got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.