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

determining date and time

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
moose155
Posts: 7
Joined: Thu Jun 10, 2010 9:46 am

determining date and time

Post by moose155 »

I need to change the action in a vxml application based on time of day and day of the week. Is there a way to pickup these values from within the vxml application?

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

Re: determining date and time

Post by support »

Hi moose155,

The following IVR code example should help you pick up the day of the week and (universal) time of of day.

dateandtime.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
  <form>
    <script>
      var currentDate = new Date();
      var month = currentDate.getMonth() + 1;
      var day = currentDate.getDate();
      var year = currentDate.getFullYear();
      currentDate = month + "/" + day + "/" + year;

      var currentTime = new Date();
      var hour = currentTime.getUTCHours();
      var minute = currentTime.getUTCMinutes();
    </script>
    <block>
      <prompt>
        The date is <value expr="currentDate"/>. The universal time is <value expr="hour"/> hours and <value expr="minute"/> minutes.
      </prompt>
    </block>
  </form>
</vxml>
You can also use the following link as reference for Date objects: http://www.w3schools.com/jsref/jsref_obj_date.asp

Regards,
Plum Support

Post Reply