Results 1 to 4 of 4

Thread: Date and Time Now

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Date and Time Now

    can someone plz give me the code to find out the date and time today (now) in C++? thanks
    Last edited by perito; Jan 9th, 2008 at 03:26 PM.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Date and Time Now

    Code:
    #include <stdio.h>
    #include <time.h>
    
    int main( )
    {
        char dateStr [9];
        char timeStr [9];
        _strdate( dateStr);
        printf( "The current date is %s \n", dateStr);
        _strtime( timeStr );
        printf( "The current time is %s \n", timeStr);
    }
    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    167

    Re: Date and Time Now

    sorry but Im a newbie :S
    is this is C or C++?
    I need it in C++
    thx

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Date and Time Now

    That would be compilable in both C and C++.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width