how would i get the current date in the format of DD/MM/YYYY, do i use
functions in time.h and how would i compile it (linking) ? 3 1953
In article <11**********************@g47g2000cwa.googlegroups .com>,
placid <Bu****@gmail.com> wrote: how would i get the current date in the format of DD/MM/YYYY, do i use functions in time.h
Yes, use time() to fetch the current time, localtime() to break
it down into a struct tm, then extract the structure members of that
that you are interested in and print them yourself.
Caution: the tm_year field is "years since 1900", so be sure to
add 1900 to the value before trying to print it as YYYY !!
and how would i compile it (linking) ?
No special compilation / linking requirements: use whatever
method is appropriate to your system to compile and link C programs.
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Walter Roberson wrote: In article <11**********************@g47g2000cwa.googlegroups .com>, placid <Bu****@gmail.com> wrote:how would i get the current date in the format of DD/MM/YYYY, do i use functions in time.h
Yes, use time() to fetch the current time, localtime() to break it down into a struct tm, then extract the structure members of that that you are interested in and print them yourself.
Caution: the tm_year field is "years since 1900", so be sure to add 1900 to the value before trying to print it as YYYY !!
and how would i compile it (linking) ?
No special compilation / linking requirements: use whatever method is appropriate to your system to compile and link C programs. -- "No one has the right to destroy another person's belief by demanding empirical evidence."
-- Ann Landers
Thanks man, got it working man
In article <de**********@canopus.cc.umanitoba.ca>, ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes: In article <11**********************@g47g2000cwa.googlegroups .com>, placid <Bu****@gmail.com> wrote:how would i get the current date in the format of DD/MM/YYYY, do i use functions in time.h
Yes, use time() to fetch the current time, localtime() to break it down into a struct tm, then extract the structure members of that that you are interested in and print them yourself.
Or use strftime:
#include <time.h>
#include <stdio.h>
int main(void)
{
time_t Now = time(NULL);
struct tm Date = *localtime(&Now);
char DateBuf[12];
strftime(DateBuf, sizeof DateBuf, "%d/%m/%Y", &Date);
puts(DateBuf);
return 0;
}
That's what strftime is for.
--
Michael Wojcik mi************@microfocus.com
Even if Jesus set up a blogging cafe in the center of Rockport, Texas
and extolled the virtues of a woman's right to choose while snapping
pictures of gay weddings with his Nokia, it would have made no
difference to this election. -- Ashlee Vance This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Norvell |
last post by:
I just noticed that recently the javascript I was using to format and
display the last modified date of my web page is always reporting the
current date instead. It used to work fine. This is true...
|
by: deko |
last post by:
This runs, but does not narrow to current week.
suggestions appreciated!
SELECT lngEid, dtmApptDate, Subject, Appt_ID
FROM qry002
WHERE (dtmApptDate BETWEEN
DateAdd("d",-weekday()+2,) And...
|
by: Ken Varn |
last post by:
I want to be able to determine my current line, file, and function in my C#
application. I know that C++ has the __LINE__, __FUNCTION__, and __FILE___
macros for getting this, but I cannot find a...
|
by: James P. |
last post by:
Hello there,
In my asp.net page using VB, I have a date text field in mm/dd/yyyy
format. When a date is entered, I'd like to validate it to make sure
the date is greater than or equal to the...
|
by: vijayk |
last post by:
Hi all,
I have a field which has data as YYYYMMDD, and I have to find the age
of the person by substracting it from current date. can you please
please advice...
thanks
|
by: Shawger Lager |
last post by:
Hi, I am new to DB2 (and SQL) and I am having some problems with the current date. I am trying to make sure the date in the table review is not past the current day using a constriant. I have tried...
|
by: seanw89 |
last post by:
I have a bit trouble in converting CURRENT DATE into a integer type as YYYYMMDD.
The following script is trying to find a day matching a date column with integer type with yesterday (CURRENT DATE...
|
by: remya1000 |
last post by:
I need to display current month,last 3months,6months and 1year records seperatly. and first i'm tring to display current month's records. and the error i received is this.
Microsoft VBScript...
|
by: bruce24444 |
last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can...
|
by: NitinSawant |
last post by:
Hello Experts,
I'm newbie to php,
I want to get date 30 day back from current date using php.
i'm able to get current date,
$currentDate= date("d-M-y",time());
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
| |