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.

Recommended Answers

All 4 Replies

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. :)

Many thanks Nav, Worked like a charm!

Cheers man :)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.