1
zite83
Formdatetime.php 12 hour format
  • 2006/10/25 19:24

  • zite83

  • Just popping in

  • Posts: 41

  • Since: 2004/10/5


I have no clue if anyone has done this or if there is even a need for it. I've tried searching for this type of hack but could not find it so I just played around with the code till I got what I wanted.

Reason for this hack is because of my users. My users range from 10 years old to 50. Such a wide range and alot of the younger viewers of my site dont understand 24 hour time. I myself have no problem using 24 hour format. Even my work schedule is in 24 hour here in the states. So I went ahead and changed the formdatetime.php file.

Original formdatetime.php
$timearray = array();
        for (
$i 0$i 24$i++) {
            for (
$j 0$j 60$j $j 10) {
                
$key = ($i 3600) + ($j 60);
                
$timearray[$key] = ($j != 0) ? $i.':'.$j $i.':0'.$j;
            }
        }
        
ksort($timearray);

Replace with
$timearray = array();
            
// AM Array **************************************************************************************//
            
for ($i 0$i 12$i++) {
                for (
$j 0$j 60$j $j 10) {
                    
$key = ($i 3600) + ($j 60);
                    if (
$i == 0){
                        
$timearray[$key] = ($j != 0) ? '12'.':'.$j.' am' '12'.':0'.$j.' am';
                        }
                    else{
                        
$timearray[$key] = ($j != 0) ? $i.':'.$j.' am' $i.':0'.$j.' am';
                        }
                }
            }
            
// PM Array **************************************************************************************//        
            
for ($i 12$i 24$i++) {
                for (
$j 0$j 60$j $j 10) {
                    
$key = ($i 3600) + ($j 60);
                    if (
$i 12){
                        
$timearray[$key] = ($j != 0) ? ($i 12).':'.$j.' pm' : ($i 12).':0'.$j.' pm';
                        }
                    else{
                        
$timearray[$key] = ($j != 0) ? $i.':'.$j.' pm' $i.':0'.$j.' pm';
                        }
                }
            }
        
        
        
ksort($timearray);

I am not much a programer. So let me know if there are any problems with it.

2
m0nty
Re: Formdatetime 12 hour format
  • 2006/10/25 19:40

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


could have saved yourself a whole bunch of time if you'd read the FAQ section or searched the site for adjusting the date/time..

then you would have found that you can set all the dates & time settings by opening language/english/global.php and scrolling to the bottom..

3
zite83
Re: Formdatetime 12 hour format
  • 2006/10/25 23:38

  • zite83

  • Just popping in

  • Posts: 41

  • Since: 2004/10/5


Does that change the time selection box of a date/time form element? Thats what I intended here. To change 0:00 - 23:50 to 12:00am - 11:50pm. So when users submit an event in lets say "news" or "extcal" the time selection box is abit more user friendly to 12 hour formated people.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!