Skip to main content
audras780
Participant
May 8, 2020
Question

Date format

  • May 8, 2020
  • 2 replies
  • 678 views

I am using variables to apply the date to the course, but the client would like 05/08/2020 and the different date formats I've tried in variables will not give me the 0 in front of the day, if needed.  Is this possible?

    This topic has been closed for replies.

    2 replies

    TLCMediaDesign
    Inspiring
    May 14, 2020

    Use this instead of a single date variable

     

    $$cpInfoCurrentDate$$/$$cpInfoCurrentMonth$$/$$cpInfoCurrentYear$$

    Inspiring
    May 14, 2020

    Doh...

    I misread it. Thought it was about REMOVING the zeroes 😉

     

    Inspiring
    May 14, 2020

    Mak a new variable with a pre value:

    DateFormat = DDMMYYYY

    And use cpInfoCurrentDateStringDDMMYYYY

    /Jacob

     

    (And if the Month first)

     

    DateFormat = MMDDYYYY

     

    Inspiring
    May 14, 2020

    Or 

     

    var d = new Date();
    var s = '';
    s = d.getDate()+'/'+(d.getMonth()+1)+'/'+d.getFullYear();

    Inspiring
    May 14, 2020
    var s = '';
    s = d.getDate()+'/'+(d.getMonth()+1)+'/'+d.getFullYear(); //withOUT leading zeros
    var date = new Date('4-1-2015'); // M-D-YYYY
     
    var d = date.getDate();
    var m = date.getMonth() + 1;
    var y = date.getFullYear();
    var dateString = (d <= 9 ? '0' + d : d) + '-' + (m <= 9 ? '0' + m : m) + '-' + y; //WITH leading zeros