|
-
Jan 3rd, 2011, 05:05 AM
#1
Thread Starter
New Member
Real time
Hi gays,
I made a program in VB6.0 and Access database.
How I can insert system date (time) in program to compare with date/time which appears in toolbar.
It is important because the documents have to folloves each to another by dates, but someone can cick on Adjust Date/Time and change the date to back. I want to block that action by compare real time and Adjust time.
Help me.
Thanks
-
Jan 3rd, 2011, 08:39 AM
#2
Re: Real time
VB6 has Date(), Time() and Now() functions. The last one returns date and time.
-
Jan 3rd, 2011, 10:52 AM
#3
Re: Real time
Those functions just return the system time, which would be changed if the user changes the system time (duh). They aren't very useful for protecting against the user changing the time. There are websites that give you time synchs, but they can be problematic. Do you have a server that you could compare times against?
My usual boring signature: Nothing
 
-
Jan 3rd, 2011, 11:35 AM
#4
Re: Real time
Oh good point. I missed this part " but someone can cick on Adjust Date/Time and change the date to back". In that case, what Shaggy said.
-
Jan 3rd, 2011, 12:19 PM
#5
Thread Starter
New Member
Re: Real time
 Originally Posted by Shaggy Hiker
Those functions just return the system time, which would be changed if the user changes the system time (duh). They aren't very useful for protecting against the user changing the time. There are websites that give you time synchs, but they can be problematic. Do you have a server that you could compare times against?
No, I have not a server to compare date (time). Maybe I can build a counter in program?
-
Jan 3rd, 2011, 12:32 PM
#6
Re: Real time
Thread Moved from General Devleoper to Classic VB6 forum
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 3rd, 2011, 01:26 PM
#7
Re: Real time
 Originally Posted by Nuvanda
No, I have not a server to compare date (time). Maybe I can build a counter in program?
Well, you can, but the problem with that approach is that the user could change the time when your program isn't running. That would be undetectable.
For when the program is actually running, the process is fairly straightforward. On startup, store Now() to a date variable. Have a timer fire every 1000 milliseconds. In the timer event you increment a counter variable. The idea being that each time the timer fires, Now() should be within a couple seconds of the date variable + counter seconds. If it's more than a few seconds off, it's reasonable to assume the user just changed the system date (or Daylight Saving just happened) and you can adjust your times accordingly.
But again, if your program isn't running you have no way of knowing if the user changed the system time.
-
Jan 3rd, 2011, 01:33 PM
#8
Re: Real time
I'm not sure what sort of mischief you're trying to guard against, or why it is critical that:
the documents have to folloves each to another by dates
You might consider though that using the usual Date(), Time(), Now() are meant to tell the user what time (and date) it is, not for creating important timestamps.
The most obvious thing to consider is that Daylight Savings Time can come or go between the creation of two of your "documents." So you might create Document A when Now() reports one time, then a minute later create Document B just after crossing back to Standard Time and have Now() report a time 59 minutes earlier.
Filesystem timestamps are generally in UTC, getting around the problem much of the time.
Date(), Time(), and Now() do not report the system time, but give the system time corrected to the current time zone (i.e. the local time). The system time is UTC.
GetSystemTime Function
None of that solves your dilemma, but should be considered if you're planning to rely on values from the intrinsic date and time functions in VB.
Maybe if you can tell us why:
the documents have to folloves each to another by dates
... we might suggest alternatives.
For example perhaps you'd be better off with a "document ID" value that gets bumped every time a new "document" is created? That might be more useful in establishing chronology (or ordinality at least).
-
Jan 3rd, 2011, 03:32 PM
#9
Thread Starter
New Member
Re: Real time
 Originally Posted by dilettante
I'm not sure what sort of mischief you're trying to guard against, or why it is critical that:
You might consider though that using the usual Date(), Time(), Now() are meant to tell the user what time (and date) it is, not for creating important timestamps.
The most obvious thing to consider is that Daylight Savings Time can come or go between the creation of two of your "documents." So you might create Document A when Now() reports one time, then a minute later create Document B just after crossing back to Standard Time and have Now() report a time 59 minutes earlier.
Filesystem timestamps are generally in UTC, getting around the problem much of the time.
Date(), Time(), and Now() do not report the system time, but give the system time corrected to the current time zone (i.e. the local time). The system time is UTC.
GetSystemTime Function
None of that solves your dilemma, but should be considered if you're planning to rely on values from the intrinsic date and time functions in VB.
Maybe if you can tell us why:
... we might suggest alternatives.
For example perhaps you'd be better off with a "document ID" value that gets bumped every time a new "document" is created? That might be more useful in establishing chronology (or ordinality at least).
It means: one working order per day. Those are jobs during the months. Each day you have new working order. You can not back the day before to get a working order, because it is to late. You got a working order which you can do that day or any day later, but you must not go back with date. But customers trick me by changing date in toolbars.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|