473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

system date

Wen
Is it easy to get the system date in c++?
Somethings like in SQL or VB?
--

Regards,
Wen
Jul 22 '05 #1
10 8224
"Wen" <We************@hccnet.nl> wrote...
Is it easy to get the system date in c++?
Somethings like in SQL or VB?


// get the system calendar time
std::time_t tt = std::time(0);
// convert it into tm struct
std::tm ttm = *std::localtime(&tt);
// extract the values for day, month, year
int mday = ttm.tm_mday;
...

Victor
Jul 22 '05 #2
Wen
Thank you Victor,

Your codes are to difficult for me.

Best Regards,
Wen

"Victor Bazarov" <v.********@comAcast.net> schreef in bericht
news:nsqCb.324347$Dw6.1094815@attbi_s02...
"Wen" <We************@hccnet.nl> wrote...
Is it easy to get the system date in c++?
Somethings like in SQL or VB?


// get the system calendar time
std::time_t tt = std::time(0);
// convert it into tm struct
std::tm ttm = *std::localtime(&tt);
// extract the values for day, month, year
int mday = ttm.tm_mday;
...

Victor

Jul 22 '05 #3
On Fri, 12 Dec 2003 23:19:20 +0100 in comp.lang.c++, "Wen"
<We************@hccnet.nl> was alleged to have written:
Thank you Victor,
Your codes are to difficult for me.


Each thing that follows "std::" is a name of something in the standard
library. Using Victor's post for clues, look up the names "time_t",
"time()", "localtime()" etc. in the index of your favorite reference.

See also section 13.12 thru 13.14 in Steve Summit's C FAQ. It is always
good to check the FAQ before posting. You can get the FAQ at:
http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #4

"David Harmon" <so****@netcom.com> schreef in bericht
news:3f***************@news.west.earthlink.net...
On Fri, 12 Dec 2003 23:19:20 +0100 in comp.lang.c++, "Wen"
<We************@hccnet.nl> was alleged to have written:
Thank you Victor,
Your codes are to difficult for me.


Each thing that follows "std::" is a name of something in the standard
library. Using Victor's post for clues, look up the names "time_t",
"time()", "localtime()" etc. in the index of your favorite reference.

See also section 13.12 thru 13.14 in Steve Summit's C FAQ. It is always
good to check the FAQ before posting. You can get the FAQ at:
http://www.eskimo.com/~scs/C-faq/top.html

Thanks David!

I've token a look in the C FAQ and found also these code's. (q20.31) But
still I dont kwow how to use it.
I'm a starter, use C++ about 2 months.
My compiler (dev c++, bloodshed 4.981) doenst know <time_t>, where can I get
the time libary?

Which include do I need? Is this a void of int ?

dayofweek(y, m, d) /* 0 = Sunday */
int y, m, d; /* 1 <= m <= 12, y > 1752 or so */
{
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}

Best Regards,
Wen
Jul 22 '05 #5
"Kees Hoogendijk" <ni********@haalditweg-hcopleidingen.nl> wrote...

"David Harmon" <so****@netcom.com> schreef in bericht
news:3f***************@news.west.earthlink.net...
On Fri, 12 Dec 2003 23:19:20 +0100 in comp.lang.c++, "Wen"
<We************@hccnet.nl> was alleged to have written:
Thank you Victor,
Your codes are to difficult for me.
Each thing that follows "std::" is a name of something in the standard
library. Using Victor's post for clues, look up the names "time_t",
"time()", "localtime()" etc. in the index of your favorite reference.

See also section 13.12 thru 13.14 in Steve Summit's C FAQ. It is always
good to check the FAQ before posting. You can get the FAQ at:
http://www.eskimo.com/~scs/C-faq/top.html

Thanks David!

I've token a look in the C FAQ and found also these code's. (q20.31) But
still I dont kwow how to use it.
I'm a starter, use C++ about 2 months.


What book are you reading?
My compiler (dev c++, bloodshed 4.981) doenst know <time_t>, where can I get the time libary?

Which include do I need? Is this a void of int ?


This is definitely a void of int. Use <get_yourself_a_good_C_book>
include. Once you used it, open the book and study. Nothing will
replace a good study.
Jul 22 '05 #6
Hallo Victor,
That boek we has a Dutch name, in English is something like "to the battle
in C++"
I had about 25 hours lesson, now I must make a program for end
"examination" and I've got 2 weeks time to do it.
So, I need the help of this group.
Thanks voor your tip. If I've got more time I'll get a good c book.
Best Regards
Wen

"Victor Bazarov" <v.********@comAcast.net> schreef in bericht
news:XDHCb.530486$HS4.4053055@attbi_s01...
"Kees Hoogendijk" <ni********@haalditweg-hcopleidingen.nl> wrote...

"David Harmon" <so****@netcom.com> schreef in bericht
news:3f***************@news.west.earthlink.net...
On Fri, 12 Dec 2003 23:19:20 +0100 in comp.lang.c++, "Wen"
<We************@hccnet.nl> was alleged to have written:
>Thank you Victor,
>Your codes are to difficult for me.

Each thing that follows "std::" is a name of something in the standard
library. Using Victor's post for clues, look up the names "time_t",
"time()", "localtime()" etc. in the index of your favorite reference.

See also section 13.12 thru 13.14 in Steve Summit's C FAQ. It is always good to check the FAQ before posting. You can get the FAQ at:
http://www.eskimo.com/~scs/C-faq/top.html

Thanks David!

I've token a look in the C FAQ and found also these code's. (q20.31) But
still I dont kwow how to use it.
I'm a starter, use C++ about 2 months.


What book are you reading?
My compiler (dev c++, bloodshed 4.981) doenst know <time_t>, where can I

get
the time libary?

Which include do I need? Is this a void of int ?


This is definitely a void of int. Use <get_yourself_a_good_C_book>
include. Once you used it, open the book and study. Nothing will
replace a good study.

Jul 22 '05 #7
"Kees Hoogendijk" <ni********@haalditweg-hcopleidingen.nl> wrote...
Hallo Victor,
That boek we has a Dutch name, in English is something like "to the battle
in C++"
I had about 25 hours lesson, now I must make a program for end
"examination" and I've got 2 weeks time to do it.
So, I need the help of this group.
Thanks voor your tip. If I've got more time I'll get a good c book.


Kees,

A C++ book is unlikely to cover the C Standard library in depth
needed for your program. That's why I strongly recommend a C
book (even if you haven't got any time, find the time and visit
your favourite computer book shop).

Here is my code expanded to fully executable form:

#include <ctime>
#include <iostream>

int main()
{
std::time_t tt = std::time(0);
std::tm ttm = *std::localtime(&tt);
std::cout << "Today is day " << ttm.tm_mday
<< " of the month " << ttm.tm_mon + 1
<< " of the year " << ttm.tm_year + 1900
<< std::endl;
}

The same program in C would look like this

#include <time.h>
#include <stdio.h>

int main()
{
time_t tt = time(0);
struct tm ttm = *localtime(&tt);
printf("Today is day %d of the month %d of the year %d\n",
ttm.tm_mday, ttm.tm_mon + 1, ttm.tm_year + 1900);
return 0;
}

Now, if it doesn't give you enough information to proceed, you
will _have_ to ask more particular questions.

Victor
Jul 22 '05 #8
Wen
Victor,
Thank you very much!!Your code works!

Which book will you recommen, do you have a ISBN for me?
Best Regards,
Wen
"Victor Bazarov" <v.********@comAcast.net> schreef in bericht
news:J7MCb.382941$275.1236876@attbi_s53...
"Kees Hoogendijk" <ni********@haalditweg-hcopleidingen.nl> wrote...
Hallo Victor,
That boek we has a Dutch name, in English is something like "to the battle in C++"
I had about 25 hours lesson, now I must make a program for end
"examination" and I've got 2 weeks time to do it.
So, I need the help of this group.
Thanks voor your tip. If I've got more time I'll get a good c book.


Kees,

A C++ book is unlikely to cover the C Standard library in depth
needed for your program. That's why I strongly recommend a C
book (even if you haven't got any time, find the time and visit
your favourite computer book shop).

Here is my code expanded to fully executable form:

#include <ctime>
#include <iostream>

int main()
{
std::time_t tt = std::time(0);
std::tm ttm = *std::localtime(&tt);
std::cout << "Today is day " << ttm.tm_mday
<< " of the month " << ttm.tm_mon + 1
<< " of the year " << ttm.tm_year + 1900
<< std::endl;
}

The same program in C would look like this

#include <time.h>
#include <stdio.h>

int main()
{
time_t tt = time(0);
struct tm ttm = *localtime(&tt);
printf("Today is day %d of the month %d of the year %d\n",
ttm.tm_mday, ttm.tm_mon + 1, ttm.tm_year + 1900);
return 0;
}

Now, if it doesn't give you enough information to proceed, you
will _have_ to ask more particular questions.

Victor

Jul 22 '05 #9
"Wen" <We************@hccnet.nl> wrote...
Which book will you recommen, do you have a ISBN for me?


Since it's a C book, I do not know the most recent advances
in the field of C programming and its description in books.
Please consider asking in comp.lang.c (and looking in their
FAQ first, then in archives, I am sure the "best book on C"
question has been asked more than once already) and visiting
http://www.accu.org for book reviews.

Victor
Jul 22 '05 #10
Thank you once more, Victor.
I'll!
Best Regards,
Wen
"Victor Bazarov" <v.********@comAcast.net> schreef in bericht
news:z73Db.48978$8y1.196444@attbi_s52...
"Wen" <We************@hccnet.nl> wrote...
Which book will you recommen, do you have a ISBN for me?


Since it's a C book, I do not know the most recent advances
in the field of C programming and its description in books.
Please consider asking in comp.lang.c (and looking in their
FAQ first, then in archives, I am sure the "best book on C"
question has been asked more than once already) and visiting
http://www.accu.org for book reviews.

Victor

Jul 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
0
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
11
by: Mike9900 | last post by:
How can I get the real system date/time if the user fakes the date, for example by setting the system date back. -- Mike
3
by: Carlos Lozano | last post by:
I have requirement to pause the system clock until a certain event (Win XP). Then the clock will be resumed to the real time. I think it can be done using core functions and/or redirecting the...
1
by: shyam vashista | last post by:
i have problem in validation check for system date with server date problem::: If i change my system date as september 30, 2006 and use validation for filling form as current date as oct30,...
5
by: adie | last post by:
hi, can anyone help me out with this. the requirement is to display a time (any time) from a distinct timezone (lets say EST) on a webpage but to make available the conversion to the user local...
15
by: iffa n wanie | last post by:
Develop a library information system that provides the following functionalities: a) Add New Patron b) Search Patron c) Check Out Book The patron ID is unique and is generated automatically...
4
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system...
2
by: samvb | last post by:
Hi, I have just finished a program that uses ms access and depends on system date to do certain things. just when i was testing it, a friend suggested that i change system date to see how it reacts....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.