using php and javascript
I'm wanting to turn short dates in my .xml files into long dates
5/28/10 = May 28, 2010
first the working javascript I found that formats today
so I figured it would be easy to work for me by adding just a few lines and modifying the varible "now"Code:<script language="Javascript"> <!-- var dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") var monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") var now = new Date document.write("Today is " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " "+now.getDate() +".") //--> </script>
to test I creaed the following code
What I've done only gives me a blank page.Code:<script language="Javascript"> <!-- var dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") var monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") <?php $file = 'xml/bev.xml'; $xml = simplexml_load_file($file); echo ' var now = Date(\'m-d-y\', '.$xml->messages[0]->vdate.') document.write("Today is " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " "+now.getDate() +".")' ?> //--> </script>
$xml->messages[0]->vdate should be equal to 5/17/10
any ideas?



Reply With Quote

Bookmarks