0

Hi again,

i have got a site that calls 5 different tables on the database and they all have a date field, when calling and using the while loop all the $rows[] so to speak are named differently.
The problem is, i have this code to change the date layout

function Date(){
$date = $row['date']; 
$date = strtotime($date); 
$date = date('d/n/y', $date); 
echo $date;

How do i change it so i can modify all the various $rows[]?
eg

function Date(){
$date = $row2['date']; 
$date = strtotime($date); 
$date = date('d/n/y', $date); 
echo $date;

or

function Date(){
$date = $row4['date']; 
$date = strtotime($date); 
$date = date('d/n/y', $date); 
echo $date;

Thanks for your time in looking.

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by sanjaypandit
0

Pass $row as a parameter to this date function and return the changed value.
Eg.

function changeDate($date) {
 $newdate = date('d/n/y',strtotime($date)); 
 return $newdate;
}

Call this function wherever applicable. :)

0

hi 2 all ,
i have a problem in search according time period,

my table name "stats" have field id(int), ip(var char), counter(int),add_date(date time)

now i want a search on following ways

1. i want to show sum of counter according weekly >>>means weekly stats of counter
2. i want to show sum of counter according month>>> monthly stats of counter
3. i want to show sum of counter according yearly>>> yearly stats of counter

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.