# Real Web Client datetime and timezone

**URL:** <https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181>\
**Category:** Classic Servoy\
**Created:** [November 12, 2010, 11:51am UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181 "2010-11-12T11:51:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rossent](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rossent](https://forum.servoy.com/u/rossent)\
**Post date:** [November 12, 2010, 11:51am UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/1 "2010-11-12T11:51:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [November 13, 2010, 9:40pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/2 "2010-11-13T21:40:00Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [November 14, 2010, 2:56am UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/3 "2010-11-14T02:56:07Z")

</div>

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:

> **[Files - Web Client Utils - ServoyForge](https://www.servoyforge.net/projects/webclientutils/files)**
>
> Redmine

Put the jar in your /application\_server/plugins folder.

Then do something like this:

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [November 14, 2010, 11:16am UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/4 "2010-11-14T11:16:45Z")

</div>

great tip Patrick, thanks!

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [November 18, 2010, 9:40am UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/5 "2010-11-18T09:40:45Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [January 13, 2011, 1:55pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/6 "2011-01-13T13:55:49Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [January 13, 2011, 2:12pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/7 "2011-01-13T14:12:03Z")

</div>

Best way to know is to try it! ![;)]( "Wink")

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [January 13, 2011, 2:27pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/8 "2011-01-13T14:27:35Z")

</div>

I did. It did not work. That’s why I asked. ![:)]( "Smile")

Dean

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [January 13, 2011, 2:44pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/9 "2011-01-13T14:44:32Z")

</div>

I suppose the API is too old although it doesn’t look like it.  
What kind of error do you have in the log?

---

<div class="post-metadata">

**Author:** ![Westy](https://avatars.discourse-cdn.com/v4/letter/w/9de053/32.png) [@Westy](https://forum.servoy.com/u/Westy)\
**Post date:** [January 13, 2011, 3:48pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/10 "2011-01-13T15:48:50Z")

</div>

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

Dean Westover

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [January 13, 2011, 4:11pm UTC](https://forum.servoy.com/t/real-web-client-datetime-and-timezone/13181/11 "2011-01-13T16:11:17Z")

</div>

![:lol:]( "Laughing")

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:

```auto
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:

```auto
var js = "var d = new Date().toUTCString();";
plugins.WebClientUtils.executeClientSideJS(js, globals.callbackMethod, ['d']);

```
