mahfooz
03-06-2007, 12:01 AM
i have two textfields, user select dates from a popup calender and and wants to know the days between these two dates while using PHP
can u buddy help me?????
can u buddy help me?????
|
Click to See Complete Forum and Search --> : date difference mahfooz 03-06-2007, 12:01 AM i have two textfields, user select dates from a popup calender and and wants to know the days between these two dates while using PHP can u buddy help me????? aussie girl 03-06-2007, 02:46 AM have a look at the DateDiff() function NightShift58 03-06-2007, 05:48 AM datediff() is a MySQL function, not PHP. <?php $ts_date1 = strtotime($date1); $ts_date2 = strtotime($date2); $ts_diff = $ts_date2 - $td_date1; // diff in seconds ?> aussie girl 03-06-2007, 08:35 AM OOPS, well that was embarrassing I always assume people are using databases, my bad datediff() is a MySQL function, not PHP. <?php $ts_date1 = strtotime($date1); $ts_date2 = strtotime($date2); $ts_diff = $ts_date2 - $td_date1; // diff in seconds ?> mahfooz 03-06-2007, 11:09 PM thanks for replying but the problem ist that i got time from textfields and it PHP takes them as string and therefore i m facing difficulties to calculate day differences between two dates: jignesh1 03-07-2007, 07:58 AM the strtotime() function should convert the date to time i think that wat NightShift58 is trying to say $ts_date1 = strtotime($_POST['date1']); $ts_date2 = strtotime($_POST['date2']); NightShift58 03-07-2007, 08:08 AM the strtotime() function should convert the date to time i think that wat NightShift58 is trying to say $ts_date1 = strtotime($_POST['date1']); $ts_date2 = strtotime($_POST['date2']); No, actually not. Usually, dates selected in <SELECT> come in 3 parts: month, day and year. If you want my thoughts in detail, it would be this:<?php $date1 = $_POST['year1'] . "-" . $_POST['month1'] . "-" . $_POST['day1']; $date2 = $_POST['year2'] . "-" . $_POST['month2'] . "-" . $_POST['day2']; $ts_date1 = strtotime($date1); $ts_date2 = strtotime($date2); ?>But the OP will have to know how and what to concatenate because you and I can only assume things. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |