CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 1999
    Location
    Pakistan
    Posts
    207

    Finding out the system date

    I am using _strdate function to find out the system date but its not Y2k compliant, means that its giving date in the form 03/04/99. I want the date in the form 03/04/1999. How I can solve this problem?
    Zulfi.


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Finding out the system date

    the GetSystemTime api fills a SYSTEMTIME structure that contains a 4 digit wYear member.


  3. #3
    Join Date
    Apr 1999
    Location
    Pakistan
    Posts
    207

    Re: Finding out the system date

    Thanks for your suggestion but its giving me some problem
    I am doing the following things:
    LPSYSTEMTIME lpSystemTime;
    GetSystemTime(lpSystemTime);
    int k= lpSystemTime->wYear;
    when I check the value through debugger k = 19595
    which is wrong k should be 1999.
    I tried making k UINT but this also didnt work. Actually the value
    in lpSystemTime->wYear is itself 19595.




  4. #4
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Finding out the system date

    How about:

    #include < afx.h >

    CTime tTime = CTime::GetCurrentTime();

    CString szTemp = tTime.Format( "%m/%d/%Y - %H:%M:%S" );

    The string szTemp will equal something like:

    05/13/1999 - 03:55:19

    (Note the capital Y as in %Y to give the complete year with the century)

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

  5. #5
    Join Date
    Apr 1999
    Location
    Pakistan
    Posts
    207

    Re: Finding out the system date

    Thanks, its running fine no problem now.
    Zulfi.


  6. #6
    Join Date
    May 1999
    Posts
    35

    Re: Finding out the system date

    Try this
    SYSTEMTIME st;
    GetSystemTime(&st);
    printf("Year : %d",st.wYear);
    Ksheeraj

    39639,Leslie St.
    Apt #157
    Fremont USA 94538

  7. #7
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: Finding out the system date

    Can I add one another related query here?

    Assume that one user has his/hers Windows Date setting to YYMMDD and another user has his/hers Windows Date setting to DDMMYY, and I want to make sure that
    a) The chosen format is in principle retained, ie, not force Japanses/Swedish users to go to the continnental format and vice versa
    b) To show the year using 4 digits

    How can I get the current Windows Date settings in a format like %y%m%d or %d%m%y and then programmatically replace
    %y with %Y.

    This is giving us some headache, as we need to internationalis our app and also make sure dates are displayed retaining regional settings and being Y2K compliant.... (or at least visually compliant)

    Thanks for your help.....

    Sally


  8. #8
    Join Date
    Sep 2004
    Posts
    156

    Re: Finding out the system date

    I too got the same problem .

    My application is not running Sweden,denmark until the regional settings are changed to that of UK.

    Can anyone help to run the code with default settings or programmatically set the regional settings

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

Featured