Solved

Datepicker

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Form submit issue 11 56
CSS Divs in Safari 3 20
jQuery Scroll Speed 3 18
Angular - ng-if worked but why like this? 5 12
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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 …
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)

744 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