Server to ping to get exact UTC time? And Time zone information? - ping

I'm making a program that has a function that can only be run at a certain time. I want to make ti so people can't just change the clock time on their computer to make it work. Is there a place I can ping online that will return the exact time?
Also, because I don't want them to be able to cheat with time zones, but I want to incorporate them, is there a way to find out the time zone a host computer is in?
Thanks.

Related

how to change automatically UTC time to current local time in my web application.

In my web application like eCommerce site. Every projects have time limit.I will display time left details in each and every projects.i am using UTC time.how to convert current localtime for every users.For example, USA have 4 or 5 different time zone.i am using php codeigniter and mysql for my web application
If I was you, I would keep all times on your server side UTC and only convert to local time in the client via JavaScript. However, dealing with client time is tricky, since you can't really know their wall time.
I have seen 3 approaches:
1) Use var offset = new Date().getTimezoneOffset();
Probably the best way of getting the client system timezone in an automatic fashion.
2) Try to figure out the timezone by the client IP.
If you need to do the time rendering on your server after all, this might me the only automatic way you can do it. It is very error prone though, because your clients might be using proxies, VPNs etc. Also, the geoIP databases might not be accurate enough.
3) Let the user set the timezone.
This is playing it safe. the user can decide. You can also kepp the setting in a cookie or such.
The momentjs timezone library might help you with all three approaches.

Google Cloud SQL and time zones

I'm developing an app that meant to run only in Israel.
All of our tables contains times at Israeli time (Tel Aviv time).
because the SQL in GCP doesn't support default timezone and time zone convert I got stuck.
how can I convert times between time zones?
let me remind you that Israel has a light saving time change.
Now you have the ability to set the time zone in Cloud SQL. See https://cloud.google.com/sql/docs/mysql-flags. The limitation is that the time zone needs to be specified as offsets to UTC, such as '+10:00'. It does not support named time zones like 'Europe/Helsinki'.
Cloud SQL now supports named time zones. See a list here: https://cloud.google.com/sql/docs/mysql/flags#timezone-names
When using timezone names, automatic adjustment to daylight saving time is supported.
What is weird is that even though when explaining named time zones it gives the example Europe/London, in the actual list that's missing. The closest equivalent is Europe/Dublin, which is functionally the same although their summer time is considered "standard" so they switch to winter time.
THIS ANSWER IS OBSOLETE
On Google Cloud SQL you cannot currently set your own time zone. If you need to change the time zone on your instance, please get in touch with cloud-sql#google.com.

mysql save date from different datetime locals

I'm having hard time to decide on the right approach for data saving from different time zones:
I'm building an application that supposed to serve users from all over the world.
I have a table named Events which saves events the users inserted.
In this table there are Start_Time and End_Time columns of the event, which I some time need to run a select query according to does columns, and in relevant to user's current time.
I'm thinking about what the best approach for saving does times in the database. obviously I have some lack of knowledge in the time zones field.
For now i'm saving all the times as current UTC time stamp, and i'm not sure that its the right way to do so.
can anyone please provide some guidelines or documents about to right way to store it ?
hey according to my understanding you have a application that send request to this database on behalf of user, and user has its own date and time zone.
I would recommend to change your request time zone on application level to UTC. bring your application and database to same page and then after processing you can convert it back to local time zone.
what application language your are using?

Mysql saving user's and server's current time difference

I have a web server which will be serving people from around the world.
The time is a really important matter in my application, since a lot of queries are taking the time in consideration.
I need a way to store user's and server's time differences.
For example:
User login to server and send its current time.
Server's save the current time difference in mySql server
Every every time the server needs to use user's time in a query he knows how to calculate it since
it knows the difference..
What i really need is the server's ability to calculate user's time according to server's own time.
I've read about using UTC time but i didn't really understand how to implement it...
Let's say you are in the US and i am in the UK. If we both check the UTC time at the same time (with whatever code/method) we should see the same result. Check out the different ways of getting UTC timestamps in milliseconds. Then, in theory, if you sync everything by UTC time (including the server) you don't really need to be aware of timezone offsets because these offsets are only relevant if you consider the server time is based on its local timezone.
In MySQL you can get a unix timestamp with UNIX_TIMESTAMP(). As far as i know it has granularity to the second, not millisecond (so you will get the number of seconds since 1970). You can also check out UTC_TIME() and UTC_TIMESTAMP().

get machine time in air/as3

Is there a way to get a reliable machine time that cannot be altered by changing the time/date on a mobile device or computer?
I'm looking to find a way to see time elapsed in an air app where you can...
run the app
change the system time (back an hour, or change the date forward by two weeks, etc.)
run the app again with the correct time passed
any ideas how to implement this without relying on server connection?
I feel fairly confident saying it can't be done. Without a remote server to ping, all the app knows is what the OS tells it - and if the app isn't running, it can't be collecting its own data independently of the OS.
The closest you could get would be storing the system time at app shutdown, then comparing that to the system time on app startup to see if the OS' clock has been turned back - if the current time is before the previous time, you know something's up. Even then, the data about the last known system time has to be stored somewhere locally - which means the user is free to edit it if they want.
You could also mess with having the app running in the background constantly, or even as a service, though that moves out of the viability of using AIR - and even then, time would only pass while the system was on, and only if the user decides to let the background process continue running.
If your problem is measuring the elapsed time between two moments, getTimer should do the job.