Solved

Datepicker

Posted on 2014-04-04
3
228 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now