Server Datetime

Questions, tips and tricks and techniques for scripting in Servoy

Server Datetime

Postby Providence1 » Thu Sep 23, 2010 2:03 am

Is there any function to call the system datetime? I'm trying to compare it to the locale date time and zone.

Thanks in advance!
Providence
Providence1
 
Posts: 456
Joined: Tue Aug 17, 2004 2:36 am
Location: New York, NY

Re: Server Datetime

Postby 4xjbh » Thu Sep 23, 2010 2:58 am

These should sort you out.

var servertime = application.getServerTimeStamp();

var clienttime = application.getTimeStamp();
Regards,

James
4xjbh
 
Posts: 146
Joined: Fri Feb 24, 2006 8:06 am
Location: Brisbane, Australia

Re: Server Datetime

Postby Providence1 » Thu Sep 23, 2010 10:44 pm

I'm on Servoy 3.5.10. For some reason I'm getting the same datetime for each of them... application.getServerTimeStamp() is not picking up the time on the server on which it is running. It's picking up the datetime zone as calculated by the locale preference...

Code: Select all
var serverTime = utils.dateFormat(application.getServerTimeStamp(), 'MM/dd/yyyy hh:mm z');
var clientTime = utils.dateFormat(application.getTimeStamp(), 'MM/dd/yyyy hh:mm z');


clientTime returns: 09/24/2010 12:08 EST
serverTime returns: 09/24/2010 12:08 EST

Locale Preferences is set to Sydney Australia and it's the 23rd here...
Providence
Providence1
 
Posts: 456
Joined: Tue Aug 17, 2004 2:36 am
Location: New York, NY

Re: Server Datetime

Postby jcompagner » Fri Sep 24, 2010 10:33 am

in 3.5 you should get the you do get the time of the server but it will when transferred to the client will add your timezone offset

so if the server says "10:00" in timezone GMT (0) and you are in +1 then you will see on the client 11:00 (because it shows you the time in your locale of the actual "event")

In 4 and higher you can enable the property "servoy.use.client.timezone"
if you enable that then you will see "10:00" even if it is "11:00" at your place.
Because that will make sure you see the exact string representation of the date seen on the server.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 11 guests

cron