Yahoo! Developer Network Blog

« Previous | Main | Next »


September 26, 2006

getTime - Our First Utility Web Service

getTime is a handy service for building AJAX applications and learning how to work with XML and web services. When called, getTime returns the current time on the Yahoo! server, in your choice of XML, serialized PHP, or JSON.

The first application using getTime is the countdown timer on hackday.org. We're using the serialized PHP result, unserialze it and pull the value out of the array.

$timeUrl = "http://developer.yahooapis.com/TimeService/V1/getTime?appid=YahooHackDay&output=php";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $timeUrl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$result = curl_exec($ch);
$result = unserialize($result);
$timestamp = $result['Result']['Timestamp'];

Yes, this may be overkill ... :)

Dan Theurer

Posted at September 26, 2006 9:15 AM | Permalink

Bookmark this on Delicious

Subscribe

YDN Blog: Get Yahoo! Developer Network Blog on your personalized My Yahoo! home page.

Add To My RSS Feed

YDN Link Blog: Get Yahoo! Developer Network Linkblog on your personalized My Yahoo! home page.

Add To My RSS Feed

Recent Readers

Copyright © 2010 Yahoo! Inc. All rights reserved. Copyright | Privacy Policy

Help us continue to improve the Yahoo! Developer Network: Send Your Suggestions