Jump to content

Recommended Posts

Hi, I'm trying to create a form that captures users data and one of the fields are the time/date of when the user submitted the form, which I would like to record in mySQL. My column in mySQL is of the DATETIME type.

 

Here is the PHP I'm using to acquire UK time.

[pre]<?php echo $datetime = date("l, F j, Y, g:i a", time() - date("Z")) ?>[/pre]

 

The variable I'm trying to post is $datetime however I'm registering 0000-00-00 00:00:00's in mySQL. Can someone please give me the correct php to use to get the UK time to be inserted in the mySQL database column. Please note I'm a novice at php and mysql, can some one tell me without going into to much detail? I've tried to read various websites offering info but still cant understand it.  :(

 

Regards

Jassi

Link to comment
https://forums.phpfreaks.com/topic/90416-posting-php-time-to-mysql/
Share on other sites

are you trying to set a certain time or current time?

 

current can be added with the mySQL value now()

 

if your trying to post a specific time then you're best start is by printing out the value and making sure it matches what you want it to be,

that line looks a little off to me

Hi I'm trying to set the current time I've read about the now() value however how would I query to insert this into the database? I would like it to be stored in the time column. I'm currently adding the rest of the values of my form like this:

 

[pre]//This gets all information from the form

$title=$_POST['title'];

$firstname=$_POST['firstname'];

$lastname=$_POST['lastname'];

$address=$_POST['address'];

$town=$_POST['town'];

$county=$_POST['county'];

etc..[/pre]

 

[pre]//Writes the information to the database

mysql_query("INSERT INTO `contracts` VALUES ('$title', '$firstname', '$lastname', '$address', '$town', '$county', '$postcode', '$telephone', '$email', '$quotation', '$rangeselection', '$measurements', '$information', '$username')") ;[/pre]

 

Regards

Jassi

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.