开发者

php export todays date xml or json

开发者 https://www.devze.com 2023-03-11 23:00 出处:网络
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

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>";
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消