1
exbanious
Forms and time select
  • 2006/4/23 4:28

  • exbanious

  • Not too shy to talk

  • Posts: 113

  • Since: 2004/5/30


I was curious if anyone knows of a way to alter "XoopsFormDateTime" to display a twelve 12 hour format, instead of the 24 hour w/15 minute intervals?

2
exbanious
Re: Forms and time select
  • 2007/7/7 2:37

  • exbanious

  • Not too shy to talk

  • Posts: 113

  • Since: 2004/5/30


So after some time, I have been able to answer my own question .
Just in case others wish to show XoopsFormDateTime in a 12 hour (ie. 8:00 AM, 5:00 PM) format minus the 15 minute intervals. It's sloppy code, I know, but it seems to work. However, use at your own risk... it works alright for extcal.

Change your XoopsFormDateTime.php to this:



function XoopsFormDateTime($caption$name$size 15$value=0)
    {
        
$this->XoopsFormElementTray($caption' ');
        
$value intval($value);
        
$this->addElement(new XoopsFormTextDateSelect(''$name.'[date]'$size$value));
        
$timearray = array();
        for (
$i 0$i 24$i++) {
            for (
$j 0$j 60$j $j 60) {
                
$key = ($i 3600) + ($j 60);
                if (
$i 1){
                    
$t 12;
                    
$timearray[$key] = ($j != 0) ? $t.':'.$j $t.':0'.$j.' AM';
                } else if (
$i 12 ){
                    
$timearray[$key] = ($j != 0) ? $i.':'.$j $i.':0'.$j.' AM';
                } else if (
$i == 12) {
                    
$t $i ;
                    
$timearray[$key] = ($j != 0) ? $i.':'.$j $t.':0'.$j.' PM';
                } else if (
$i 12) {
                    
$t $i 12;
                    
$timearray[$key] = ($j != 0) ? $i.':'.$j $t.':0'.$j.' PM';
                }
            }
        }
        
ksort($timearray);
        
$datetime $value getDate($value) : getdate(time());
        
$timeselect = new XoopsFormSelect(''$name.'[time]'$datetime['hours'] * 3600 600 ceil($datetime['minutes'] / 10));
        
$timeselect->addOptionArray($timearray);
        
$this->addElement($timeselect);
    }

3
jilong
Re: Forms and time select
  • 2007/7/11 3:17

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


Hi exbanious,

how could you save the date and time?

Here is the code i call the XoopsFormDateTime on edituser.php

I change this from XoopsFormTex, the calendar appear on edit user form, but the date not save, the value display as "Array"

Do i need to change more on this?
$dob_text = new XoopsFormDateTime(_US_DOB'dob'1010$xoopsUser->getVar('dob''E'),_US_DOB);

4
exbanious
Re: Forms and time select
  • 2007/7/12 21:31

  • exbanious

  • Not too shy to talk

  • Posts: 113

  • Since: 2004/5/30


i should have been more clear....
this works on 2.2.*, but when i just tested it on 2.*, the time seems to work correctly, but the calendar shows up wrong initially. (meaning, it shows default date as 1969))
it did seem to save correctly for me though. on extcal and news.

not sure about your situation though.
is the calendar date and time displaying correctly when you edit a user's profile?

everything after XoopsFormDateTime is using the wrong form elements in your code.

try this:

$dob_text = new XoopsFormDateTime_US_DOB'dob'15$xoopsUser->getVar('dob''E')));


i think it should work(?)

depending on how you have saved the dob data the first time, it won't show up correctly in the calendar unless its was saved as unix timestamp format originally, however it should update the info when it is saved.

hope this helps..

5
jilong
Re: Forms and time select
  • 2007/7/13 3:34

  • jilong

  • Just popping in

  • Posts: 61

  • Since: 2007/1/10


look like the XoopsFormDateTime not really work for my site. when i use this format the result will show as 'array'

When i try this XoopsFormTextDateSelect it show me the correct result '1980-3-11', but the problem is everytime when i click into edituser.php the date field will change back 1970-1-1.

Resized Image

is that any other file i need to make a change?

6
lesage
Re: Forms and time select
  • 2007/10/15 3:12

  • lesage

  • Just popping in

  • Posts: 2

  • Since: 2007/10/10


tell me how can i get the selected or entred value?

$birth_date = new XoopsFormDateTime(_ST_BIRTH, "birth",15,0);


after submitting ,when i try $_POST['birth'] i receive Array
as result;

7
Catzwolf
Re: Forms and time select
  • 2007/10/15 10:05

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Maybe this thread will be of some help to you:

https://xoops.org/modules/newbb/viewtopic.php?topic_id=58596&forum=28&post_id=275018#forumpost275018

ATB

Catz

Login

Who's Online

166 user(s) are online (90 user(s) are browsing Support Forums)


Members: 0


Guests: 166


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits