Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Strftime Mingw don't work

Thread Tools

Re: Strftime Mingw don't work

Keith Thompson
Posts: n/a
"Bertram" <(E-Mail Removed)> writes:
> I try format date with compiler Mingw con function strftime.
> time_t t;
> char buffer[100];
> The option tha I use is:
> strftime(buffer,sizeof(buffer),DayDate="%d.%B.%Y.% A Time%H:%M:%S
> WeekYear=%U %W" ,(localtime ((time (&t), &t))));
> printf ("BUFFER=%s\n", buffer);
> But the option: %U or %W don't work!

How exactly does it not work? What output did you expect, and what
output did you actually get?

It works for me with MinGW under Cygwin, and should work with
any conforming C compiler. Here's the test program I used; I've
modified it from your code so it's a bit less convoluted (e.g.,
no assignments or comma operators in parameter expressions):

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

int main(void) {
time_t time_now = time(NULL);
struct tm *tm_now = localtime(&time_now);

char buffer[100];

size_t result = strftime(buffer,
sizeof buffer,
"%d.%B.%Y.%A Time%H:%M:%S WeekYear=%U %W",
if (result == 0) {
fprintf(stderr, "strftime() failed\n");

printf ("BUFFER=\"%s\"\n", buffer);

return 0;

And here's the output:

BUFFER="02.January.2013.Wednesday Time09:12:29 WeekYear=00 00"

Keith Thompson (The_Other_Keith) Removed) <>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Reply With Quote

Thread Tools

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 Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Strftime Mingw don't work Lew Pitcher C Programming 7 01-05-2013 06:01 PM
Windows GCC Support (Mingw & Mingw-w64) xeno fears Python 1 10-04-2009 06:40 PM
[g++ mingw eclipse] How do I setup Eclipse to use MinGw's g++ compiler? Sam Smith C++ 0 10-18-2004 11:36 AM
strftime not working as expected Bryan O'Malley C++ 8 02-17-2004 08:34 AM
gcc 3.3, solaris 8, compile error - 'strftime', 'localtime', etc. "not declared" Bimal C Programming 1 08-20-2003 12:33 PM