Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Print Date in text format after picking from Grav Form datepicker WordPress

  • SOLVED

Hello there guys, I'm trying find a way to dynamically print the date in"text format" (Thursday, January 1st 2016) after picking date from the ui date picker in a gravity form.

I need to print/display this "text format" date next to the date field AND on the post created by the form.

Can anyone help?

Thanks

Answers (2)

2016-01-28

Romel Apuya answers:

Sent u PM

2016-01-29

Hariprasad Vijayan answers:

Hi,

Try this in javascript file

jQuery( document ).ready( function() {
document.getElementById("input_1_1").onchange = function() {fun_display_date()};
function fun_display_date() {
var x = document.getElementById("input_1_1");
var weekday = new Array(7);
weekday[0]= "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";
var d = new Date(x.value);
var w = weekday[d.getDay()];
var m = month[d.getMonth()];
suffix = '';
switch(d.getDate()) {
case '1': case '21': case '31': suffix = 'st'; break;
case '2': case '22': suffix = 'nd'; break;
case '3': case '23': suffix = 'rd'; break;
default: suffix = 'th';
}

jQuery(x).parent().append(w+', '+ m + ' ' + d.getDate()+suffix+', '+d.getFullYear());
}
});


replace <em>input_1_1</em> with your datepicker input box id.


Regards,
Hari