Skip to content

Instantly share code, notes, and snippets.

@qbart
Created October 31, 2012 22:49
Show Gist options
  • Save qbart/3990460 to your computer and use it in GitHub Desktop.
Save qbart/3990460 to your computer and use it in GitHub Desktop.
nginx current time from server in seconds
HttpClient httpClient = new DefaultHttpClient();
HttpHead req = new HttpHead("http://xxxxx/_now");
HttpResponse res = httpClient.execute(req);
Header header = res.getFirstHeader("x-now");
String value = header.getValue();
Long time = Long.parseLong(value) * 1000l;
Date now = new Date(time);
...
location /_now {
add_header x-now $date_gmt;
access_log off;
return 204;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment