Show current month in text, possible?


#1

var now = new Date();    dateFormat(now, “dddd, mmmm dS, yyyy, h:MM:ss TT”);
     // Saturday, June 9th, 2007, 5:46:21 PM
$(’#date’).append(now);

So this is the jquery code I am using that is supposed to display the current date in that span, but it isn’t working.  Is there a way I could just display the current date? possibly just the month?


#2

Hello Pablo,

Welcome and congrats on joining us in the Unbounce community!  I am sure this is possible, but might I recommend sharing your landing page and a little more context to your situation?  I might not be the best one to help you with this, but I am sure you are at the right place.

Best regards,

Joe


#3

Hello! The page is http://l.adammesh.com/10top-stocks-2015/. All I’m looking to do is change the month automatically


#4

Anyone?


#5

Hey Pablo,

I’m not sure that the code you have above is valid Javascript. I’ve gone ahead and put together a solution that should achieve the functionality you’re looking for.

The first step will be to choose a default word in your text and wrap it in a span with id=“month” in the source of your text box. In your case, it could look like this:

Brand New For October 2015!

Next, paste the script found here in your Javascript section of your landing page with placement ‘Before Body End Tag’:

https://gist.github.com/noahub/fec2ae22859ba50e94c6

Once saved and republished, the word that is wrapped in this span will be replaced with the current month on your live landing page.

I hope this helps Pablo!


#6

I am so close to figuring this out.

I’d like to insert today’s date into a text box. 2 things are stumping me.

  1. In the source of the text box, how do you add an id=date so that it is filled in by the java script?

  2. What is the exact java script that outputs todays date in this format: 04/16/2018.

Thanks so much for your help.