CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    41

    printing date and time, formatting

    For an assignment i have to do, i have to print the data and time like dos does. this would be:

    11/03/2003 1:40p

    i used a long and then used ctime to get:

    Mon Nov 03 13:40:05 2003


    is there any easy way to just get it to format correctly the way i want it?

  2. #2
    Join Date
    Oct 2002
    Location
    St. Louis
    Posts
    27
    Try COleDateTime

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: printing date and time, formatting

    Originally posted by J3adSeed
    For an assignment i have to do, i have to print the data and time like dos does. this would be:

    11/03/2003 1:40p

    i used a long and then used ctime to get:

    Mon Nov 03 13:40:05 2003


    is there any easy way to just get it to format correctly the way i want it?
    See strftime().

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Aug 2003
    Posts
    41
    I guess i'm having some trouble here. The problem is i'm limited to storing the date and time as a 32 bit number. so use an integer and the ctime() function.

    it seems that these functions use the tm structure. how can i convert from this integer to a tm struct. once i can do that, it seems it would be pretty easy to get the individual pieces from the time and date.

  5. #5
    Join Date
    Aug 2003
    Posts
    41
    nevermind i think i figured that part out.

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449
    Did you check the strftime() function? It does exactly what you are stating you want to do (if not, please clarify what it does not do that you want it to do).

    Regards,

    Paul McKenzie

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