Skip to main content
audras780
Participant
May 8, 2020 8:46 PM UTC
Question

Date format

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 is closed to new replies. Start a new post to keep the conversation going.

    5 replies

    TLCMediaDesign
    Inspiring
    May 14, 2020 3:20 PM UTC

    Use this instead of a single date variable

     

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

    Translate
    Inspiring
    May 14, 2020 3:24 PM UTC

    Doh...

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

     

    Translate
    Inspiring
    May 14, 2020 2:21 PM UTC

    Mak a new variable with a pre value:

    DateFormat = DDMMYYYY

    And use cpInfoCurrentDateStringDDMMYYYY

    /Jacob

     

    (And if the Month first)

     

    DateFormat = MMDDYYYY

     

    Translate
    Inspiring
    May 14, 2020 3:10 PM UTC

    Or 

     

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

    Translate
    Inspiring
    May 14, 2020 3:23 PM UTC
    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
    Translate