Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Datepicker

Posted on 2014-04-04
3
Medium Priority
?
244 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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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 54

Expert Comment

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

Is this part of your other question?
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

963 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