Real Web Client datetime and timezone

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

Real Web Client datetime and timezone

Postby rossent » Fri Nov 12, 2010 1:51 pm

Hi all,

Is there a way to get the "real client" datetime (and timezone) in the Web Client - by "real client" I mean the actual client machine where the browser is running and not the Servoy web client instance running on the application server.

The Servoy application.getTimeStamp() when used in a web client returns the datetime of the application server and not the actual user datetime.

Thanks for your help!
Rossen Totev
Argos Software
rossent
 
Posts: 288
Joined: Wed Dec 31, 2008 2:03 pm

Re: Real Web Client datetime and timezone

Postby jcarlos » Sat Nov 13, 2010 11:40 pm

I've never done this, but I suppose that you'll need to capture the client's time zone and then perform a conversion. Check Servoy Developer application node to see is there is something that will help you to capture the client's time zone.

JC

(Posted from my PDA)   
jcarlos
 
Posts: 578
Joined: Thu May 04, 2006 8:55 pm
Location: Palo Alto, California USA

Re: Real Web Client datetime and timezone

Postby ptalbot » Sun Nov 14, 2010 4:56 am

You need the date to be evaluated on the client side (in the browser), you can do that using the Web Client Utils plugin.

You will find it on ServoyForge of course:
https://www.servoyforge.net/projects/webclientutils/files

Put the jar in your /application_server/plugins folder.

Then do something like this:
Code: Select all
function onAction(event) {
   var js = "var d = new Date().toUTCString();";
   plugins.WebClientUtils.executeClientSideJS(js, callbackMethod, ['d']);
}

function callbackMethod(d) {
   var date = new Date(d);
        // now do anything you want with this date.
   application.output(date);
}
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Real Web Client datetime and timezone

Postby Harjo » Sun Nov 14, 2010 1:16 pm

great tip Patrick, thanks!
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Real Web Client datetime and timezone

Postby Andrei Costescu » Thu Nov 18, 2010 11:40 am

In 6.0 application.getTimeStamp() for WC will simulate client date/time based on server date/time and client timezone.
But if you need the "real" time of the client machine that is the way to go, yes. (Web Client Utils plugin)
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Real Web Client datetime and timezone

Postby Westy » Thu Jan 13, 2011 3:55 pm

function onAction(event) {
var js = "var d = new Date().toUTCString();";
plugins.WebClientUtils.executeClientSideJS(js, callbackMethod, ['d']);
}

function callbackMethod(d) {
var date = new Date(d);
// now do anything you want with this date.
application.output(date);
}


Can this be done in Servoy 3.5?

Dean Westover
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: Real Web Client datetime and timezone

Postby ptalbot » Thu Jan 13, 2011 4:12 pm

Best way to know is to try it! ;)
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Real Web Client datetime and timezone

Postby Westy » Thu Jan 13, 2011 4:27 pm

I did. It did not work. That's why I asked. :)

Dean
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: Real Web Client datetime and timezone

Postby ptalbot » Thu Jan 13, 2011 4:44 pm

I suppose the API is too old although it doesn't look like it.
What kind of error do you have in the log?
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Real Web Client datetime and timezone

Postby Westy » Thu Jan 13, 2011 5:48 pm

"Function keyword found in this script" when click verify button in method editor.

Dean Westover
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: Real Web Client datetime and timezone

Postby ptalbot » Thu Jan 13, 2011 6:11 pm

:lol:

How do you create a function in 3.5 then?
You need one to receive a callback from the web page.

Perhaps create a global method, with this code inside:
Code: Select all
var date = new Date(d);
// now do anything you want with this date.
application.output(date);

call it 'callbackMethod'

Then put this in a button onAction event for example:
Code: Select all
var js = "var d = new Date().toUTCString();";
plugins.WebClientUtils.executeClientSideJS(js, globals.callbackMethod, ['d']);
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC


Return to Web Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron