Solved

Datepicker

Posted on 2014-04-04
3
232 Views
Last Modified: 2014-04-04
Hi,

I am using the datePicker, I want on the onload event to set the Datepicker to date's date and time.

like this: 04/04/2014 07:11 am

$(document).ready(function () {

//here I want to set today's date and time

});


$('#TimeOccurredTxt').timepicker({
      hourGrid: 4,
      minuteGrid: 10,
      timeFormat: 'hh:mm tt'
});


$('#DateIdentifiedtxt').datetimepicker({
      timeFormat: "hh:mm tt"
});

Thank you,
Lulu
0
Comment
Question by:lulu50
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39977878
$(document).ready(function () {

    var theDay = $.datepicker.formatDate('d/m/yy', new Date());

    var todayDate = new Date();
    var hours = todayDate.getHours();
    var minutes = todayDate.getMinutes();
    var seconds = todayDate.getSeconds();
    var format = "AM";
    if (hours > 11) {
        format = "PM";
    }
    if (hours > 12) {
        hours = hours - 12;
    }
    if (hours === 0) {
        hours = 12;
    }
    if (minutes < 10) {
        minutes = "0" + minutes;
    }


    alert(theDay + ' ' + hours + ':' + minutes + ' ' + format);


});

Open in new window

0
 

Author Closing Comment

by:lulu50
ID: 39978069
Thank you
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39978082
Your welcome!

Is this part of your other question?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question