Jump to content

display specific number of characters


ianhaney50
Go to solution Solved by Ch0cu3r,

Recommended Posts

Thank you so much, works perfect

 

I just found another little issue when testing, the record date is being inserted into the mysql table as 00/00/0000 instead of the actual date, I am using datepicker, the INSERT query is below

// insert the new record into the database
				if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))
Link to comment
Share on other sites

Most likely MySQL is unable to interpret the date being in DD/MM/YYYY format. If you have set your column as date(time) format then MySQL requires dates to be inserted in YYYY-MM-DD format. So before inserting the date you need to convert it to use that format.

 

You can use PHP's DateTime object to do so


// your date value in DD-MM-YYYY format
$date = '4/10/2015';

// convert date to YYYY-MM-DD format
$dt = new DateTime($date);
$date = $dt->format('Y-m-d');
Link to comment
Share on other sites

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.