sholladay Posted February 27, 2016 Share Posted February 27, 2016 I realize this is rookie stuff, I don't have enough experience to string this together from them info on this site regarding this to make it work. Can someone help me? This shows current time, but if there's a 0 it drops it. So, for 3:03, it does 3:3. I want it to show current date and time (not skipping 0's) - military time. Can anyone help? jQuery(document).ready(function() { var now = new Date(); jQuery("#RESULT_TextField-4").val(now.getHours()+":"+now.getMinutes()); Link to comment Share on other sites More sharing options...
dsonesuk Posted February 27, 2016 Share Posted February 27, 2016 (edited) You have to format it dynamically if less than ten function zerolessthan10(value) { if(parseInt(value) < 10) { return "0"+value; } else { return value; } } $(document).ready(function() { var now = new Date(); var hours = zerolessthan10(now.getHours()); var mins = zerolessthan10(now.getMinutes()); $("#RESULT_TextField-4").val(hours+":"+mins); }); Edited February 27, 2016 by dsonesuk 1 Link to comment Share on other sites More sharing options...
sholladay Posted February 29, 2016 Author Share Posted February 29, 2016 You have to format it dynamically if less than ten function zerolessthan10(value) { if(parseInt(value) < 10) { return "0"+value; } else { return value; } } $(document).ready(function() { var now = new Date(); var hours = zerolessthan10(now.getHours()); var mins = zerolessthan10(now.getMinutes()); $("#RESULT_TextField-4").val(hours+":"+mins); }); Thank you! This worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now