Developer Network Home - Help

getTime - Our First Utility Web Service (Yahoo! Developer Network blog)

« Ruby Developer Center Launches | Main | Flickr loves JSON »

getTime - Our First Utility Web Service

September 26, 2006

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

rss     Add to My! Yahoo

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings