This topic is locked

problem with date

5/1/2007 1:02:31 AM
PHPRunner General questions
E
evan_ad2000 author

Hi,
I am having problems with dates. In my DB there is a table called `itemtransaction` where a serial number and date of transaction is entered into the DB. The date is derived by using the now() function in PHP.
Later on when a customer sends a product back for service, a form has to be filled up. A serial number is entered and the system checks the DB to find the date it was sent out. Finding the date was not a problem. I set the date using $_SESSION[] variable so that it preloads into the page. I also set the type of the field to be of DATE under the Visual Editor Edit As settings. The data that is shown on the page does not tally with the date in the DB. What is wrong here? If i use a text field, then everything is ok.
Also, how can I calculate the difference between 2 dates that were created using the now() function?
Another problem I came up with is that i tried to create a custom table at by using the Datasource Tables tabs and selecting the types of fields i want. After that I use a custom SQL query to generate the table. The query works alright in phpMyAdmin, but the date doesnt show in the web page. Why is this so?
With Thanks,

Evan

Alexey admin 5/1/2007

Evan,
I need to take a closer look at your pages to help you.

Please publish your project on Demo account then send a URL along with instructions on reproducing the issue to support@xlinesoft.com

Also, how can I calculate the difference between 2 dates that were created using the now() function?

Use this code snippet to calculate a difference between two dates in YYYY-MM-DD HH:MM:SS format:

$date1="2007-01-01";

$date2=now();

$tm1=db2time($date1);

$tm2=db2time($date2);

$time1=mktime($tm1[3],$tm1[4],$tm1[5],$tm1[2],$tm1[1],$tm1[0]);

$time2=mktime($tm2[3],$tm2[4],$tm2[5],$tm2[2],$tm2[1],$tm2[0]);
$diff=$time2-$time1;

echo "seconds elapsed from the beginning of year: ".$diff;

Sergey Kornilov admin 5/1/2007

Here are several examples of calculating date difference in PHP:

http://www.google.com/search?sourceid=navc...date+difference
In regards to the custom query it looks like date format is not correct.

What exactly is the value of date field that don't come up on the web page?

E
evan_ad2000 author 5/7/2007

Evan,

I need to take a closer look at your pages to help you.

Please publish your project on Demo account then send a URL along with instructions on reproducing the issue to support@xlinesoft.com
Use this code snippet to calculate a difference between two dates in YYYY-MM-DD HH:MM:SS format:


Hi,
Thanks for the tip but I found another way around it. I used the following to find the number of days between 2 dates. Problem is, i tried to preset a checkbox's value to 1 or 0 but no matter how many days it is, the check box is always empty. Help?
$age = floor((mktime()-strtotime($pDate))/86400);

$_SESSION["age"] = $age;
if($age <= 365)

{

$_SESSION["warranty"] = 1;

}

else

{

$_SESSION["warranty"] = 0;

}
Thanks,

Evan