time_t

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • magix

    #1

    time_t

    I saw below code:

    std::time_t now;
    std::time ( &now );
    std::stringstre am stream;
    stream << "output_" << asctime(localti me( &now )) << ".txt" <<
    std::flush;

    How to convert asctime(localti me( &now )) to be timestamp format like
    20060930130102 ?

    Thanks & Regards.


  • Phlip

    #2
    Re: time_t

    magix wrote:
    How to convert asctime(localti me( &now )) to be timestamp format like
    20060930130102 ?
    strftime()

    --
    Phlip
    http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


    Comment

    • Gavin Deane

      #3
      Re: time_t


      magix wrote:
      I saw below code:
      >
      std::time_t now;
      std::time ( &now );
      std::stringstre am stream;
      stream << "output_" << asctime(localti me( &now )) << ".txt" <<
      std::flush;
      >
      How to convert asctime(localti me( &now )) to be timestamp format like
      20060930130102 ?
      How about this:

      #include <ctime>
      #include <sstream>
      #include <string>

      int main()
      {
      std::time_t now;
      std::time ( &now );
      std::stringstre am stream;
      stream << "output_" << asctime(localti me( &now )) << ".txt" <<
      std::flush;

      std::string s = stream.str();

      // Write code to modify the contents of s to meet your needs.
      }

      If you have trouble writing the the code to modify the contents of s to
      meet your needs, FAQ 5.8 explains how to post a question about code you
      are having trouble with.

      Follow all those guidelines and you will get the help you need.

      What you will have a lot less luck finding of course is anyone who will
      donate their time and effort to write all your code for you. Depending
      on whether this is your own programming project or something for a
      class or school, asking others to do your work for you without showing
      how you've attempted it yourself and where you got stuck is called
      either laziness or cheating.

      Gavin Deane

      Comment

      • magix

        #4
        Re: time_t


        "Phlip" <phlipcpp@yahoo .comwrote in message
        news:Bc9Tg.163$ NE6.0@newssvr11 .news.prodigy.c om...
        magix wrote:
        >
        > How to convert asctime(localti me( &now )) to be timestamp format like
        >200609301301 02 ?
        >
        strftime()
        >
        --
        Phlip
        http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
        >
        >
        Thanks. this is exactly what I'm looking for.


        Comment

        Working...