You are viewing limited content. For full access, please sign in.

Question

Question

Time and Date Stamp not using military time

asked on February 16, 2016

I tried to use the javascript provided. But it shows as military time. The field does not hold when sending it to Laserfiche also. Anyway help on how to modify a field to show the date and time of a signature? 

0 0

Replies

replied on March 21, 2017

Hello Chynna,

I know I am late to the response here...this is how we solved it:

if (d.getHours() < 12) { var a = "AM";}
else if (d.getHours() == 12) { var a = "PM";}
else (d.getHours() > 12) { var a = "PM"; hours = hours - 12;}
1 0
replied on March 22, 2017

Thanks Mark, I think Laserfiche got tired of time request since they added that feature in 10.2. But I still might need this for another form.

0 0
replied on February 16, 2016 Show version history
$(document).ready(function () {
  $('.signature').click(timestamp);
 
  function timestamp() {
    
    var d = new Date();
    var minutes = d.toLocaleTimeString();
    
    if (minutes < 10) {var minutes = "0" + minutes;}
    
    if (d.getHours() < 12) { var a = "AM";}
    else {var a = "PM";}  
    
    if ($(this).hasClass('signature')) {
      $('.timesign input').val(d.getHours() + ":" + minutes + a);
    }
  }
});

Update....I used w3schools to find this script. However, I am stuck with this now. I know this has to be a simple fix.

 

0 0
replied on February 17, 2016

Hi Chynna,

The time you are looking for in your above example (2:12:47 PM) is sandwiched between the additions you made ("14"+":"+minutes+"PM"). Your "minutes" variable is all you need, which comes from the ".toLocaleTimeString()" method.

Also, your "if" statement is true when the clicked element has the "signature" class. However, the function only runs if an element with the "signature" class is clicked, so the "if" statement is not necessary. Try out the following JavaScript:

$(document).ready(function(){
  $('.signature').on('click', function(){
    var d = new Date();
    $('.timesign input').val(d.toLocaleTimeString());
  });
});

You can also get the current date using ".toLocaleDateString()", and a combination of the two using ".toLocaleString()". More information can be found here, however you can get the current date by using a "Date" field and setting the default value to "Today". 

Also, fields that are set to "Read-only" from the form layout page are not sent to Laserfiche if their values are set by JavaScript. You can instead set the fields to read only using JavaScript:

$('.readOnly input').prop('readOnly', true);

Let me know if this works for you!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.