-
November 3rd, 2003, 02:31 PM
#1
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?
-
November 3rd, 2003, 02:42 PM
#2
-
November 3rd, 2003, 03:06 PM
#3
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
-
November 3rd, 2003, 03:22 PM
#4
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.
-
November 3rd, 2003, 03:27 PM
#5
nevermind i think i figured that part out.
-
November 3rd, 2003, 03:28 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|