CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 date functions

Print topic Send  topic

Author Message
Ron Borkent
Posted: 02/11/2002, 1:57 AM

Maybe you already have something like this but for those that are stil having trouble with converting date formats with mysql here are two functions I wrote:

// show mysql format 0000-00-00 as european format 00-00-0000

function showdbdate($field)
{
$day = substr($field, 8, 2);
$month = substr($field, 5, 2);
$year = substr($field, 0, 4);
$field= $day . "-" . $month . "-" .$year;
return $field;
}

//insert update format 00-00-0000 to db as format 0000-00-00

function dbdate($field)
{
$day = substr($field, 0, 2);
$month = substr($field, 3, 2);
$year = substr($field, 6, 4);
$field= $year . "-" . $month . "-" .$day;
return $field;
}


Add these functions in modules under global functions

Use the first one in before show event like this
$fldyour_date_field= showdbdate($fldyour_date_field);

and the second one in the before insert or before update event like this:

$fldyour_date_field=dbdate($fldyour_date_field);

Hope it is usefull for someone

Ron

ocougar
Posted: 06/26/2002, 3:51 AM

Thanks,
was very useful ! ;-)
Walter

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.