We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Define date format

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Define date format

Post by soso »

Hi,

I'm newbie on this forum and vxml language. I've a question.

By default, the date format is under Wed Jul 02 2008 10:15:59 GMT+0200, with this code:

Code: Select all

<var name="startDate" expr="Dat()"/>
I would like to create the date with mm/dd/yy.

How do I proceed?

Thanks by advance.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code to format date

Post by support »

Hi,

You can use this IVR code to achieve the date format that you are looking for. Note what's inside of the IVR tag, <script>.

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
  <form>
    <script>
      var currentTime = new Date();
      var month = currentTime.getMonth() + 1;
      var day = currentTime.getDate();
      var year = currentTime.getFullYear();
      currentTime = month + "/" + day + "/" + year;
    </script>
    <block>
      <prompt>
        The date is <value expr="currentTime"/>.
      </prompt>
    </block>
  </form>
</vxml>
Hope this helps.

Regards,
Plum Support
Last edited by support on Wed Feb 24, 2010 3:38 pm, edited 5 times in total.

soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Post by soso »

Thanks for your answer.

Why can i may +1 in the month var?

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Clarification of IVR code for date format

Post by support »

You have to add + 1 because the getMonth() function for the Date object returns the number of month from 0-11.

See here for more IVR information on the Date object:

http://www.tizag.com/javascriptT/javascriptdate.php

Regards,
Plum Support
Last edited by support on Sun Dec 27, 2009 5:48 pm, edited 1 time in total.

soso
Posts: 62
Joined: Tue Apr 22, 2008 8:11 am

Post by soso »

Ok, very thanks.

Post Reply