Time/Date Stamp for csv.php file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bessie
    New Member
    • Aug 2006
    • 6

    Time/Date Stamp for csv.php file

    I have a registration form that loads into a dava.csv file (code below). I want to add a time/date stamp so that each time someone registers, the last column in the spreadsheet shows the time/date. I've tried several things but all have failed and the form stops working. I'm taking classes this fall on programming but need to do this now, unfortunately. Any help? :confused:

    [PHP] <?php
    @extract($ POST);
    if(is_writable( 'data.csv'))
    {
    $fp = fopen('data.csv ','a');
    $content = "\"$fRSVP\",\"$ fRepName\",\"$f RepTitle\",\"$f Lunch\",\"$fPre fix\",\"$fFirst Name\",\"$fLast Name\",\"$fTitl e\",\"$fCompany \",\"$fAddress\ ",\"$fCity\",\" $fProvince\",\" $fPostalCode\", \"$fTelephone\" ,\"$fFax\",\"$f Email\r\n"
    fwrite($fp,$con tent);
    fclose($fp);
    header("Locatio n: return URL");
    }
    else
    {
    echo'File is not writable';
    }
    ?>
    [/PHP]
    Last edited by Niheel; Aug 5 '06, 02:06 PM.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Do you mean like:

    Code:
    $DateTime = strftime("%d/%m/%Y %H:%M:%S", time());
    (gives you e.g. 04/08/2006 00:13:15) and then adding $DateTime to your string?

    Ronald :cool:

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Originally posted by ronverdonk
      Code:
      $DateTime = strftime("%d/%m/%Y %H:%M:%S", time());
      You don't need that call to time, if you leave it out PHP assumes NOW

      Code:
      $DateTime = strftime("%d/%m/%Y %H:%M:%S");
      I was going to suggest

      Code:
      $DateTime = Date("%c");

      Comment

      • bessie
        New Member
        • Aug 2006
        • 6

        #4
        Where do I place the date stamp? Yesterday I tried putting it after email and before the /r/n but caused the form to stop working. I want the date stamp to appear at the end of each row (each row contains one registrant).

        Thanks!

        Comment

        • bessie
          New Member
          • Aug 2006
          • 6

          #5
          This almost worked - the form functioned but I got a () as a result - at least I'm closer.

          \",$today()\r\n ";

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            If $today is your string holding the date/time-stamp, you don't specify the parentheses, just $today

            Ronald :cool:

            Comment

            • bessie
              New Member
              • Aug 2006
              • 6

              #7
              ",\"$datetime=n ow()\",\r\n";

              This is now working but gives me the info in seconds. However, I can use Excel to translate for the date. Still don't know how to get both the date & time except to repeat the code and use Excel for time translation for the second entry. I suspect there is a better way.

              Comment

              • bessie
                New Member
                • Aug 2006
                • 6

                #8
                Just figured out that the code works perfectly for time/date just by choosing the right cell formatting in Excel. YIPEEEEEEEEF! TTFN.

                Comment

                • ronverdonk
                  Recognized Expert Specialist
                  • Jul 2006
                  • 4259

                  #9
                  Well, Good Luck!

                  Ronald :cool:

                  Comment

                  Working...