I have a LAN connection with my project and I need to display a running time and date of with labels anyone have an idea? is it curdate and curtime?

Recommended Answers

All 9 Replies

you can get current date use now() . like this

Now.Date.ToString()
        Now.TimeOfDay.ToString()
        Now.Year.ToString()
        Now.Month.ToString()

Hope this will help you , :)

Regards

you can get current date use now() . like this

Now.Date.ToString()
        Now.TimeOfDay.ToString()
        Now.Year.ToString()
        Now.Month.ToString()

Hope this will help you , :)

Regards

not that, I need to get the other computer's time and date from my 1 computer

You can also sync your computer clock with the server. From the command shell you can do

D:\temp>net time /?
The syntax of this command is:

NET TIME

[\\computername | /DOMAIN[:domainname] | /RTSDOMAIN[:domainname]] [/SET]

Then you can just get the date/time from your own computer. You can get just the date/time returned from the server by

D:\temp>net time \\jim-pc
Current time at \\jim-pc is 2012-02-28 18:39:22

The command completed successfully.

Codeproject has some code to get remote date/time info here.

Codeproject has some code to get remote date/time info here.

I have a better idea:

-Server will update a table for the current time and date per minute
-Client will select that updated field

:twisted:

Better to sync with the server clock when the app starts. It's not a good idea to repeatedly update a time field in the database (or to repeatedly poll for a new time value). It's an unnecessary load on the dbserver (requires an app to run continuously on the server to do the update) and if it is only updating once a minute than for 59 seconds out of each minute the time will be incorrect. If the app is only running for an hour or two then the two clocks shouldn't get too out of sync. If that's a concern then the app could resync the clocks (for example) once an hour.

It's an unnecessary load on the dbserver (requires an app to run continuously on the server to do the update)

Yeah I thought of that after an hour I posted in the thread...lol, how would I do that sync?

You could do it from outside the app in a cmd file by

net time \\servername /set

do

net time /?

for other options. You could also do it from inside the app by spawning net.exe as a separate thread or external process.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.