CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Problem writing Dates back to MySQL (CC & PHP )

Print topic Send  topic

Author Message
DeWebDude
Posted: 06/19/2003, 9:53 PM

OK I have no problem reading a date from a file and displaying it in mm/dd/yyyy format. The problem I have is when I write the information back to the table that it never works.
I have tried these examples:

1---------------------------
//return date("Y/m/d", mktime (0,0,0,$month,$day,$year));
$month=strval(substr($date_value,0,2));
$day=strval(substr($date_value,4,2));
$year=strval(substr($date_value,7,4));
return date("Y-m-d", mktime (0,0,0,$month,$day,$year));


2-----------------------
list( $mm, $dd, $yyyy ) = split( "/", $fldrequested_date );
$fldrequested_date = "$yyyy-$mm-$dd";


The thing is none of these work.

I have tried a few other things as well with no luck....

Any detailed help appreciated...
RipCurl
Posted: 06/20/2003, 2:45 PM

When I run into these kidns of problems, I always take a step back to see what's wrong.

What I do is make a dummy php page with the code Im trying to execute and see if my code actually works on its own, before implementing it within CC.

So, why dont you just start off with a dummy variable, and see if your code actually works (for instance):

<?
$date = "2003-01-01"; // mysql format date
$format_date = strtotime($date); // change to Unix time stamp
// echo "$format_date<br>"; // show value of formate_date - comment out if it shows a unix time stamp
$newdate = date("m/d/y",$format_date); // change format of date to something you like
echo $newdate;
?>

So the above code takes a mysql date format, turns it into a Unix Time format, and then in PHP changes it to what I like.

So, all you have to do is play around with it, to change it to what you like. For me, I rather work with Unix Time Stamps because its just easier to convert.
DeWebDude
Posted: 06/20/2003, 7:21 PM

?<$date_value = "05-17-2003";
$month=strval(substr($date_value,0,2));
$day=strval(substr($date_value,3,2));
$year=strval(substr($date_value,6,4));
$new_date = $year ."-". $month ."-" .$day;

echo $new_date;
>?

I may have posted one of my many tries, but in the above example this works perfectly to return from the human date on the screen to MySQL date back in the db in respect to displaying the values in the right format...
The probelm is it still doesn't go into the table properly.
Any ideas what I am doing wrong ?

Thanks

   


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.