PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > How to determine curreent date and time/
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to determine curreent date and time/

Réponse
 
LinkBack Outils de la discussion
Vieux 14/04/2008, 18h14   #1
Sanchit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to determine curreent date and time/

I am using GCC on FEDORA.

I want to print current date an time. How can do that.

Thanks
-Sanchit
  Réponse avec citation
Vieux 14/04/2008, 18h21   #2
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine curreent date and time/

On 14 Apr 2008 at 17:14, Sanchit wrote:
> I am using GCC on FEDORA.
>
> I want to print current date an time. How can do that.


system("date");

  Réponse avec citation
Vieux 14/04/2008, 18h39   #3
Sanchit
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine curreent date and time/

On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam.invalid> wrote:
> On 14 Apr 2008 at 17:14, Sanchit wrote:
>
> > I am using GCC on FEDORA.

>
> > I want to print current date an time. How can do that.

>
> system("date");


Oh I forgot to mention.. I want a C function for this.
  Réponse avec citation
Vieux 14/04/2008, 18h47   #4
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine curreent date and time/

On 14 Apr 2008 at 17:39, Sanchit wrote:
> On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam.invalid> wrote:
>> On 14 Apr 2008 at 17:14, Sanchit wrote:
>>
>> > I am using GCC on FEDORA.

>>
>> > I want to print current date an time. How can do that.

>>
>> system("date");

>
> Oh I forgot to mention.. I want a C function for this.


strftime?

  Réponse avec citation
Vieux 14/04/2008, 18h49   #5
aspinall@oltrelinux.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine curreent date and time/

On 14 Apr, 19:14, Sanchit <sanchitgupt...@gmail.com> wrote:
> I am using GCC on FEDORA.
>
> I want to print current date an time. How can do that.


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

int main(){

time_t now = time(NULL);
struct tm *now_s = localtime(&now);

if(now_s == NULL)
return EXIT_FAILURE;

printf("%d-%02d-%02d %02d:%02d:%02d\n", 1900+now_s->tm_year, ++now_s -
>tm_mon,

now_s->tm_mday, now_s->tm_hour, now_s->tm_min,now_s->tm_sec);

return EXIT_SUCCESS;
}

Bye.
  Réponse avec citation
Vieux 14/04/2008, 18h54   #6
Gordon Burditt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine curreent date and time/

>I am using GCC on FEDORA.
>
>I want to print current date an time. How can do that.


In C, time() gets you the current date/time in a time_t format.
Various functions can get that into a printable string format:

ctime()
localtime() followed by strftime()
localtime() followed by asctime()


  Réponse avec citation
Vieux 14/04/2008, 20h36   #7
harsha
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine curreent date and time/

On Apr 14, 10:39 pm, Sanchit <sanchitgupt...@gmail.com> wrote:
> On Apr 14, 10:21 pm, Antoninus Twink <nos...@nospam.invalid> wrote:
>
> > On 14 Apr 2008 at 17:14, Sanchit wrote:

>
> > > I am using GCC on FEDORA.

>
> > > I want to print current date an time. How can do that.

>
> > system("date");

>
> Oh I forgot to mention.. I want a C function for this.


http://www.cs.utah.edu/dept/old/texi...19.html#SEC320
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10253 seconds with 15 queries