Questions and answers about IVR programming for Plum DEV
Moderators: admin , support
soso
Posts: 62 Joined: Tue Apr 22, 2008 8:11 am
Post
by soso » Wed Jul 02, 2008 3:35 am
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:
Post
by support » Wed Jul 02, 2008 11:25 am
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 » Wed Jul 02, 2008 12:10 pm
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:
Post
by support » Wed Jul 02, 2008 1:07 pm
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 » Wed Jul 02, 2008 1:08 pm
Ok, very thanks.