Solved

Datepicker

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
key press alert 2 32
Load data upon clicking a button 8 35
How to add a stringified JSON string to an IP address? 11 59
100% tall div not scrollable on iPhone 3 20
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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

831 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