Jump to content

Need a time picker for my php project


bambinou1980
Go to solution Solved by Ch0cu3r,

Recommended Posts

Hello all,

 

I have a form that required a time picker, with a bit of searching I found something called Moment.js and boostrap 3 timepicker from here:

https://eonasdan.github.io/bootstrap-datetimepicker/Installing/

 

 

I have installed all the dependencies via bower and everything is in place, the time picker is also showing.

Where I am confused:

 

 

1)How to keep the value of the timepicker and set it as "value" in this field:

 

                        <div class="form-group">
                            <div class='input-group date' id='datetimepicker1'>
                                <input type='text' class="form-control" value="" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>

                        <script type="text/javascript">
                            $(function () {
                                $('#datetimepicker1').datetimepicker();
                            });
                        </script>

 

 

The time picker is showing:

MM/DD/YYYY

 

but I need it:

DD/MM/YYYY

 

 

Could you please give me a quick example on how to play with this time picker?

 

I just need to record the data and send it to mysql.

 

 

Thank you!

 

Ben

 

Link to comment
Share on other sites

  • Solution

 

1)How to keep the value of the timepicker and set it as "value" in this field:

Set the value attribute for the input field to your date value, examples

<input type='text' class="form-control" value="05/09/2015" />
<input type='text' class="form-control" value="<?php echo $your_date_variable_here" />

To format the date to use

$('#datetimepicker1').datetimepicker({
    format: 'DD/MM/YYYY',
});

if you still want the the time then append the format string with ' HH:mm:ss' (without the quotes)

Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.