1
<div class="shipout">
<p style="margin:0;">Delivery: FAST & FREE</p>
<script>
Date.prototype.addDays = function(days) {
  var dat = new Date(this.valueOf());
  dat.setDate(dat.getDate() + days);
  return dat;
}

var dat = new Date();

document.write('Between ')
document.write(dat.addDays(<?php echo $_product->getData('shipout_day_from');?>))
document.write(' & ')
document.write(dat.addDays(<?php echo $_product->getData('shipout_day_to'); ?>))
</script>
</div>

How to add Class for each document.write('Between ')?

Output:

Delivery: FAST & FREE
Between Sun Mar 19 2017 06:35:17 GMT+0530 (India Standard Time) & Mon Mar 20 2017 06:35:17 GMT+0530 (India Standard Time)

Also how to shorten the date or change the date format to Between Sun Mar 19 & Mon Mar 20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.