Jump to content

How I can get server time


apicito

Recommended Posts

  • 2 months later...
  • 3 months later...

hi ,  Anybody can help me solve  this problem?

 

thank for your kindness.

 

You want to know the server time on the client side?

 

There are several ways, one of them:

 

1. Declare a variable.

     In MainForm.Scripts add the line: 

var uniGUIServerTime;

2. Now you can assign it a value:    

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniSession.AddJS('uniGUIServerTime = "' + DateTimeToStr(Now) + '";');
end;

3. Now on the client side you can use this variable

 

Best regards.

Link to comment
Share on other sites

hi, delphi developer

 

Thank you very much for your answer.

 

i have some problem.

 

step 1.  In MainForm.Scripts add the line: 

                var uniGUIServerTime;

                  

                    ok

 

step 2.

procedure TMainForm.UniFormCreate(Sender: TObject);

begin
  UniSession.AddJS('uniGUIServerTime = "' + DateTimeToStr(Now) + '";');
end;

 

                     ok

 

step 3.   use  unit   uniGUIApplication;

 

step 4 .  i make event  onbuttonclick;

 

procedure TMainForm.UniBitBtn1Click(Sender: TObject);

begin
  UniLabel1.Caption :=  UniSession.uniGUIServerTime;
end;

 

  error message  [dcc32 Error] Main.pas(40): E2003 Undeclared identifier: 'uniGUIServerTime'

 

Thank you very much for your help.

Link to comment
Share on other sites

Hi vitisan.
 

var uniGUIServerTime; - It is not delphi variable, it is a variable javascript!

You must use this:

1. 

procedure TMainForm.UniBitBtn1Click(Sender: TObject);
begin
  UniLabel1.Caption :=  DateTimeToStr(Now);
end;

or
 
2.
procedure TMainForm.UniBitBtn1Click(Sender: TObject);
begin
  UniSession.AddJS(UniLabel1.JSName + '.setText(uniGUIServerTime)');
end;

or

 
3.
procedure TMainForm.UniBitBtn1Click(Sender: TObject);
begin
  UniSession.AddJS(UniLabel1.JSName + '.setText(' + DateTimeToStr(Now) + ')');
end;

Best regards.

Link to comment
Share on other sites

You want to know the server time on the client side?

 

There are several ways, one of them:

 

1. Declare a variable.

     In MainForm.Scripts add the line: 

var uniGUIServerTime;

2. Now you can assign it a value:    

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniSession.AddJS('uniGUIServerTime = "' + DateTimeToStr(Now) + '";');
end;

3. Now on the client side you can use this variable

 

Best regards.

 

 

 

I have difficulty understanding the issue here.

 

The answer to original question seems to be as easy as:

UniLabel1.Caption := DateTimeToStr(Now);

 

I thought that the question was about the variable on the client side ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...