close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to get a dd/mm/yyyy date format from a MySQLi Recordset

Thread began 8/20/2014 2:19 pm by gary385539 | Last modified 8/21/2014 2:15 pm by Jason Byrnes | 1985 views | 5 replies |

gary385539

How to get a dd/mm/yyyy date format from a MySQLi Recordset

I am using an MySQLi recordset and when I try to display the date from a field in the recordset using my previous MySQL format code:

<?php echo(($row_RS_MbrList_Curr['dateofbirth'])?date('d/n/Y',strtotime($row_RS_MbrList_Curr['dateofbirth'])):''); ?>

it will not return anything and the page will not load. How do I get the date our of a MySQLi Recordset into dd/mm/yyyy format please?

Sign in to reply to this post

Jason ByrnesWebAssist

the code to echo a MySQLi recordset value would look like this:

<?php echo($RecordsetName->getColumnVal("ColumnName")); ?>



where RecordsetName is the name of the recordset and ColumnName is the name of the column, to format that if it is a date:

<?php echo(date("d/m/Y", strtotime($RecordsetName->getColumnVal("ColumnName")))); ?>
Sign in to reply to this post

gary385539

Thanks you Jason.

Is there a way of calculating the current age of the person from that value too?

Your help is appreciated.

Sign in to reply to this post

Jason ByrnesWebAssist

you can do that directly in the recordset if your using MySQL 5 >


SELECT TIMESTAMPDIFF(YEAR, dateColumn, CURDATE()) AS age FROM tableName

Sign in to reply to this post

gary385539

Thanks again!

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...