close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Changing the Date Format in PhpMyAdmin DB

Thread began 5/22/2012 3:26 am by salaroche | Last modified 8/16/2013 12:46 pm by Jason Byrnes | 19580 views | 16 replies |

salaroche

Changing the Date Format in PhpMyAdmin DB

Hi:

My PhpMyAdmin DB demands that the date format in the date column be: yyyy-mm-dd. Is there any way to change that format? For example to dd-mm-yyyy?

Thank you for your attention

Sign in to reply to this post

Jason ByrnesWebAssist

no, you cannot change the format that the database requires.

you can change how the date is displayed on the page though by using the date() and strtotime() functions:

php:
<?php echo(date("d-m-Y"strtotime($row_recordsetName['statecode']))); ?>
Sign in to reply to this post

salaroche

Jason:

Thank you for your reply. Could you kindly tell me where should that line of code go? The top of the page? Where?

Thank you for your attention.

Sign in to reply to this post

salaroche

Jason:

Please disregard my previous entry. I already got it.

Thank you for your attention

Sign in to reply to this post

salaroche

Jason:

Your line of code works perfectly well. Would it be possible to do the same operation in reverse? Meaning entering the date in dd-mm-yyyy format and turning it into the yyyy-mm-dd DB format before storing?

Thank you for your attention

Sign in to reply to this post

salaroche

Jason:

I changed the Date-entry format in DW to dd.mm.yyyy, but it gets stored in a scrambled line of numbers. Is there any way to change the Date entry format to dd.mm.yyyy and have it store and display correcty afterwards?

Thank you for your attention

Sign in to reply to this post

Jason ByrnesWebAssist

the format stored in the database must by yyyy-dd-mm


you can use the date() and strtotime() functions to allow you to enter the date using dd.mm.yyyy format and have it stored correctly, for exaample add code similar to this at line one of the data assist pages:

php:
<?php

if($_SERVER["REQUEST_METHOD"] == "POST")     {
  
$_POST['dateElement'] = "".((isset($_POST["dateElement"]))?date("Y-m-d"strtotime($_POST["dateElement"])):"")  ."";
}
?>



and then use code similar to this to convert it back when displaying:
<?php echo(date("d.m.Y", strtotime($row_recordsetName['dateColumn']))); ?>

Sign in to reply to this post

salaroche

jason:

Thank you for your reply.

I tried entering the code you suggested at the top of the data-entry page, but the dates are still stored in a scrambled manner, and so ar they when diaplayed in the results, details, etc., pages.

Attached please find a copy of the page where the dates are entered and of the results page where they are displayed.

Any suggestions?

Attached Files
salaroche.zip
Sign in to reply to this post

Jason ByrnesWebAssist

what do you mean exactly by "scrambled manner"? what is the data type for the column in the datebase, you should be using date.

the code i gave was an example, you need to substitute the correct form elements names. In your form, the data element is named "dateReg", so the code at the top of the page should be:


php:
<?php 
if($_SERVER["REQUEST_METHOD"] == "POST")     { 
  
$_POST['dateReg'] = "".((isset($_POST["dateReg"]))?date("Y-m-d"strtotime($_POST["dateReg"])):"")  .""

?>
Sign in to reply to this post

salaroche

jason:

OK. Since I have 3 different date fields in the data entry form, should I add three lines of code similar to the one you sent? Or can I add the other 2 date fields after "dateReg"?

Thank you for your attention

Sign in to reply to this post
loading

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...