locked
Get the Date from the CrmDateTime? RRS feed

  • Question

  • Hi,
    crmForm.all.new_date.DataValue return a DateTime like this: Fri Sep 11 00:00:00 UTC 0200 2009
    is it possible to get the Date as this format dd/mm/yyyy

    thx
    Sunday, September 6, 2009 1:11 PM

Answers

  • Try this:
    var dat = crmForm.all.new_date.DataValue;
    var day = dat.getDate() + '';
    if (day.length == 1)
    day = '0'+day;

    var month = dat.getMonth() + 1 + '';
    if (month.length == 1)
    month = '0'+month;

    var formatted = day + '/' + month + '/' + dat.getFullYear();

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Sunday, September 6, 2009 2:50 PM
    Moderator

All replies

  • Hi, Balhato.

    Try this script:

    var dat = new Date();
    var day = dat.getDate() + '';
    if (day.length == 1)
    day = '0'+day;
    
    var month = dat.getMonth() + 1 + '';
    if (month.length == 1)
    month = '0'+month;
    
    var formatted = day + '/' + month + '/' + dat.getFullYear();


    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Sunday, September 6, 2009 1:27 PM
    Moderator
  • but haw can do it from DataTime crmField
    Sunday, September 6, 2009 2:48 PM
  • Try this:
    var dat = crmForm.all.new_date.DataValue;
    var day = dat.getDate() + '';
    if (day.length == 1)
    day = '0'+day;

    var month = dat.getMonth() + 1 + '';
    if (month.length == 1)
    month = '0'+month;

    var formatted = day + '/' + month + '/' + dat.getFullYear();

    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Sunday, September 6, 2009 2:50 PM
    Moderator