SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would like to include a hidden field in a form that would "stamp" the date and time of when the form was submitted.

    Any ideas?

    Ideally I would like it to be the date/time of the server the form resides on and not the date/time of the computer which it is being submited from.

    Thanks in advance,
    John Karben

  2. #2
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can use PHP, then you can try this:

    <input type="hidden" name="date" value="<?php CURDATE(); ?>">

    then use another hidden field for the time.
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  3. #3
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Elledan I can us PHP and will give that a go.

    For the Time is the value="<?php CURTIME(); ?>" ?

    Thanks again,
    John Karben

  4. #4
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, CURTIME(); returns the time.
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  5. #5
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, my bad:

    The CURDATE() and CURTIME() functions are meant to be used with mySQL...

    For the right PHP function, look here:

    http://www.php.net/manual/en/function.getdate.php
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  6. #6
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just came across this thread - up, I'm pretty sure (not positive) that it's an SQL function. You'd use it in your SQL query, which works just fine anyway...time=CURTIME() - instead of time=$time, for example.

    However, you can use the date function in PHP if you need the data in a hidden form field, check this out:
    http://php.net/manual/en/function.date.php

    Quite useful.

  7. #7
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again Elledan for the input. Unfortunately I have little knowledge at this point in writing the correct code for either PHP or mySQL. Both languages are available to me.

    Would you mind taking a bit more time and writting out a suggested hidden form code for mySQL and PHP?


    Thanks in advance,
    John Karben

  8. #8
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm confused - do you want the code for the INSERT statement using CURDATE() in SQL, or do you want the PHP code used to stick the date in a hidden form field?

    If it's the latter, which format would you like it in?

  9. #9
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks TWTCommish, I'd like the "value=" code for whichever would work best, mySQL or PHP (or both if one or the other won't work). Please include any other code required in the .html document.

    <input type="hidden" name="date" value="_________">

    The PHP format prefered would be something like: month/day/time = 01/23/3:39pm or 01/23/15:39

    My apologies for the confusion.

    Thanks in advance,
    John Karben

  10. #10
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    month/day/Year, time:

    <input type="hidden" name="date" value="<?php print(date("m/d/Y, h:s A")); ?>">

    For a month/day/time format, use this:

    date("m/d/h:s A")
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.


Bookmarks

Posting Permissions

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