Date Format
My resultspage from dataAssist display date in this format YYYY-MM-DD but I require it as DD-MM-YYYY. I can understand that MySql date format is YYYY-MM-DD but is there any way to change in DataAssist.
My resultspage from dataAssist display date in this format YYYY-MM-DD but I require it as DD-MM-YYYY. I can understand that MySql date format is YYYY-MM-DD but is there any way to change in DataAssist.
The simplest way would be to use a custom function:
Paste this code at the top (or bottom of your page)
<?php
/*
Format MySQL Date Field to DD-MM-YYYY
----------------------------------------------------------
*/
function i8_formatMySQLDate($date) {
$d = str_replace(" ","",$date);
$d = explode('-', $date);
$d = $d[2].'-'.$d[1].'-'.$d[0];
return $d;
}
?>
You would then call the function like so:
<?php echo i8_formatMySQLDate($row_RecordSetName['datefield']); ?>
I am trying to do this also. I have it set up as 2014-02-01 and then next to that, attempting to make it show 01-02-2014.
I pasted the php at top of page, and then where I want the date to appear I have this on the page, where the first line is the default and the second line is my attempt.
Exp: <?php echo $row_consumersoffer['cat_coupon_expdate']; ?>
<?php echo i8_formatMySQLDate($row_consumeroffer['cat_coupon_expdate']); ?>
This admin field for the date is managed in DataAssist using the calendar function for the client to use. In the admin, it shows the date as 2/01/2014 but on the display page, using bindings to pull the date into the page, it reverts.
Any guidance most appreciated.
Found a solution in another thread
<?php echo date("m/d/Y", strtotime($row_consumersoffer['cat_coupon_expdate'])); ?>
http://www.webassist.com/forums/posts.php?id=2877
:-)
Glad to hear you found the solution.
Some time ago I did put up a tutorial for date formatting (examples using both server date as well as date stored in a database...here was the original tutorial: http://www.webassist.com/forums/posts.php?id=17179
Then if you use the documentation from the official php website: http://www.php.net/manual/en/function.date.php
you can adjust the format to anything you like :)
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
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.