someone help me with this php scripting?

Shimmishim

Elite Member
Feb 19, 2001
7,504
0
76
function get_date_short($date) {
$today = @gmdate('Ymd', time() + (3600 * 2));
$compare = substr($date ,0,8);

$day = substr($date, 6,2);
$month = substr($date, 4,2);
$hours = substr($date, 8,2);
$minutes = substr($date, 10,2);

if ($today == $compare) {
return "$hours:$minutes";
}

else {
return "$day/$month";
}
}

function get_date_long($date) {
$day = substr($date, 6,2);
$month = substr($date, 4,2);
$year = substr($date, 0,4);
$hours = substr($date, 8,2);
$minutes = substr($date, 10,2);

return "$day-$month-$year $hours:$minutes";
}

function get_date_archive($date) {
$month = substr($date, 4,2);
$year = substr($date, 0,4);

$month_array = array("januari", "februari", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");
$month_text = $month_array[$month - 1];

return "$month_text $year";



this script i got is from someone from germany

so the time displayed is the time in germany and the date is displayed day-month-year

how do i fix this so that the time displays central time and the date is displayed month-day-year instead?

thanks!
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
1. These are three different functions and none call each other, what are each 3 for?
2. What is the input for each one supposed to be?
3. Using @ is bad!
4. php's date(), time(), mktime(), and a few other functions should usually provide more than enough functionality, these functions seem to duplicate them in one way or another.
 

Shimmishim

Elite Member
Feb 19, 2001
7,504
0
76
Originally posted by: BingBongWongFooey
1. These are three different functions and none call each other, what are each 3 for?
2. What is the input for each one supposed to be?
3. Using @ is bad!
4. php's date(), time(), mktime(), and a few other functions should usually provide more than enough functionality, these functions seem to duplicate them in one way or another.

it's for adding a log entry to a webpage..

when you add an entry, the date, time, and author of who published shows up on the page

so any suggestions?
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
BingBongWongFooey, I think you've got the wrong idea, he's not trying to learn how to code PHP efficiently, he's trying to get his website working with the least possible amount of effort required.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Shimmishim
Originally posted by: BingBongWongFooey
1. These are three different functions and none call each other, what are each 3 for?
2. What is the input for each one supposed to be?
3. Using @ is bad!
4. php's date(), time(), mktime(), and a few other functions should usually provide more than enough functionality, these functions seem to duplicate them in one way or another.

it's for adding a log entry to a webpage..

when you add an entry, the date, time, and author of who published shows up on the page

so any suggestions?

That still says nothing about what each function actually *does*.