php export todays date xml or json
im creating a phonegap application with images that will be updated weekly, i am able to load and save the data onto the phone. However in testing i have found that many people have incorrect dates on their phone so its been difficult to tell the app when to download the new data.
is there a nifty piece of php i can include on my server that will save the current date as JSON or XML that the app can check to find the correct date(in Vancouver, Canada)? Or maybe there is already a resource that does this. As it is a phonegap app the same originator rule is not a problem.
my preferred format would be mm/dd/yyyy but if theres a good solution in anot开发者_如何学运维her format i can be flexible
thanks, tim
You'll want to use php's date function and json_encode try
<?php echo json_encode(array('now'=> date('m/d/Y')));?>
XML Example:
<?php
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<date>";
echo date("m/d/Y");
echo "</date>";
?>
精彩评论