Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007
    Posts
    1

    Unanswered: Inserting datetime from hidden field

    Hi there - I know that you can use NOW() in MySQL to add the datetime but I was wondering how I can insert the datetime using PHP into MySQL. I dont want to use timestamp.

    I have tried using <? echo date() ?> or using variables such as <? echo $date ?> where I have defined $date in the format YYYY-MM-DD HH:MMS in the hidden field but when the insert occurs the datetime field remains 0000-00-00 00:00:00.

    Any thoughts would be most appreciated.

    Thanks.

  2. #2
    Join Date
    Jun 2007
    Posts
    9
    You can use something like :
    Code:
    echo date("Y.m.d H:i",time());

  3. #3
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Why are you putting it into a hidden field? Do you need to know the difference between the time the page was loaded and the time the form was submitted? Once you have submitted the form THEN grab the date using ISPServer's PHP code.
    Code:
    $submitted_timestamp = date("Y.m.d H:i:s",time());
    Don't put it into a form field because it's then liable to XSS (cross-site-scripting) if you don't sanitise it on the server side.

Posting Permissions

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