Results 1 to 9 of 9

Thread: Real time

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    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

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Real time

    VB6 has Date(), Time() and Now() functions. The last one returns date and time.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    Re: Real time

    Quote Originally Posted by Shaggy Hiker View Post
    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?

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  7. #7
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Real time

    Quote Originally Posted by Nuvanda View Post
    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.

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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).

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    Re: Real time

    Quote Originally Posted by dilettante View Post
    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
  •  



Click Here to Expand Forum to Full Width