Skip to main content

Search

Date() format in Expression Builder

Comments

4 comments

  • Тарас_Lozynskyy

    Hi Gareth Jayne

    Use this code:

    var date = new Date();
    return date.getDate() + "/" + date.getMonth() + "/" + date.getFullYear()

    like this:

     

    Best Regards

    Taras Lozynskyy

    0
  • GarethJ

    Thanks for the quick reply.  This has formatted the date correctly but for some reason has come up as 2/5/2017 instead of 2/6/2017.  Can you think of why this could have happened?

    0
  • Тарас_Lozynskyy

    Hi Gareth Jayne, this is because month start from 0. Like here:

    So just add +1 to the month:
    var date = new Date();
    return date.getDate() + "/" + date.getMonth() + 1 + "/" + date.getFullYear()

    0
  • GarethJ

    Thank you so much for your help, that worked perfectly!

    0

Please sign in to leave a comment.