I have a rails application and i need to get the Eastern standard Time using the Time class
I am just trying to make sure that we always use eastern stand time so I can sync with a countdown every 3 seconds…
here is the code
Jquery code
$j(document).ready(function() {
refresh();
function refresh() {
$j.getJSON("/timer", function(data) {
console.log(data);
});
setTimeout(refresh, 3000);
}
});
RAILS Controller action
def refresh_timer
respond_to do |format|
format.json { render :json => Time.now}
end
end
Time.now.in_time_zone 'Eastern Time (US & Canada)'Or just use this if your server is configured to use EST:
Time.now.localtime