Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-02-2005, 06:29 AM   #1 (permalink)
lalabear
Registered User
 
Join Date: Jul 2005
Posts: 4
lalabear is on a distinguished road
help wit some codes pls

i need to put the time and date into some varieble pls help
in this order pls giv some sample or show me how its done


time variebles
HHMM <==this order

date variebles
DDMMYY<==this order
lalabear is offline   Reply With Quote
Old 07-02-2005, 04:27 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,712
redhead is on a distinguished road
look at ctime(), localtime(), gmtime()
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-02-2005, 08:13 PM   #3 (permalink)
lalabear
Registered User
 
Join Date: Jul 2005
Posts: 4
lalabear is on a distinguished road
u mean
cout <<ctime();
?
coz if so i tryed taht and it dosnt work >.<
lalabear is offline   Reply With Quote
Old 07-02-2005, 11:28 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,712
redhead is on a distinguished road
I'm too hung over, to even explain, so here is a code example.
Code:
#include <stdio.h>
#include <time.h>

int main()
{
  struct tm *tm_set;
  time_t tim, t;
  tim = time(&t);
  tm_set = localtime(&tim);
  printf("HHMM: %.2d%.2d\n", tm_set->tm_hour, tm_set->tm_min);
  printf("DDMMYY: %.2d%.2d%.2d\n", tm_set->tm_mday, tm_set->tm_mon,
             (tm_set->tm_year < 100)? tm_set->tm_year: (tm_set->tm_year -100));
  return 0;
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-03-2005, 06:16 AM   #5 (permalink)
lalabear
Registered User
 
Join Date: Jul 2005
Posts: 4
lalabear is on a distinguished road
wow taht really helps cause it really works thx but it would be even better if they can be stored in variebles cause i need to store them in an array >.<
lalabear is offline   Reply With Quote
Old 07-03-2005, 07:43 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,712
redhead is on a distinguished road
From the description:
Quote:
Broken-down time is stored in the structure tm which is defined in <time.h> as follows:
Code:
              struct tm {
                      int     tm_sec;         /* seconds */
                      int     tm_min;         /* minutes */
                      int     tm_hour;        /* hours */
                      int     tm_mday;        /* day of the month */
                      int     tm_mon;         /* month */
                      int     tm_year;        /* year */
                      int     tm_wday;        /* day of the week */
                      int     tm_yday;        /* day in the year */
                      int     tm_isdst;       /* daylight saving time */
              };
As you see, the variables are of type int, which means you can store them as int's in yoru array, or if you want to have it in the printet format like HHMM and DDMMYY then you can store them as strings, by gathering the int's into a string and store that in your array.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Take a look here pls Eyelfixit Program Design and Methods 8 02-01-2007 10:19 AM
SDE (or anyone), quick pls. Valmont Lounge 1 03-16-2005 09:06 AM
Pls help me interpret this script. infinite_root HTML, XML, Javascript, AJAX 1 09-06-2004 01:53 AM
Omg, it's been a while: fstream help pls. Valmont Standard C, C++ 6 03-13-2003 03:32 PM


All times are GMT -8. The time now is 10:47 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting