B4J Question MySQL Server Time

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I am trying to get the server time of my MySQL server into my program. I used the code
B4X:
Log(sql2.ExecQuery("SELECT CURTIME()"))
to check and it returned at these 2 times
5:24 pm (JDBC42ResultSet) com.mysql.jdbc.JDBC42ResultSet@42610720
5:26 pm (JDBC42ResultSet) com.mysql.jdbc.JDBC42ResultSet@4a4dbb70

It seems like the last digits are in HEX but I do not know how to convert that to normal time

I tried the same query on phpMyAdmin and I get the following result
CURTIME()15:53:58
Which is correct.

Please can someone assist. I have searched the forums and could not find any reference to a question like this

Thank you
 

OliverA

Expert
Licensed User
Longtime User
ExecQuery returns a ResultSet, so the log output makes sense (you're seeing a ResultSet.toString() output). For a quick video primer, go to https://www.b4x.com/etp.html and look at the "SQL & Relational Databases" video. Also, there are the following posts:
https://www.b4x.com/android/forum/threads/b4x-documentation-booklets.88985/#content (look at the SQLite tutorial. Many things will apply across DB's)
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Better to use async methods with remote databases.

[B4X] SQL with Wait For
Thank you for taking the time to post a reply

I went thru that post and could not find anything related to server time.

The problem I am trying to solve is there will be multiple remote users in many different countries. The only thing I could think about to syncro them all at the same time was the SERVER time which specified at GMT.

Since then I have written a php file to get the server time on the server and brought that into the program so that I could then start everybody at the same time.

I thought of using something like Push notifications but that as far as I see will only work on Mobile Applications, I need all the platforms. Possibly MTQQ but as this is a free program I do not want to incur costs

Basically writing a Quiz program for people in Isolation/ Lockdown (COVID-19) that can create their own groups of individual quiz games with multiple categories and is based on time. I have seen a lot of these games which goes back to a server and sometimes connection are poor and even though that person answered the fastest, they came in second or third. So the idea is to time them from when the question appears on their screen to the time they choose the correct answer, then send that to the server. The game has a 30 second wait after each round to collect from all the players and display the result of that round.

So when any of the users initiates a game then this code is run and the server time along with 5 minutes extra is put into the game file which when any of the other remote users join the game, the start time of the game is on their own computers.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…