Page 1 of 1

determining date and time

Posted: Tue Jul 13, 2010 4:56 pm
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?

Re: determining date and time

Posted: Wed Jul 14, 2010 8:56 am
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