Ruby

Convert WebKit/Chrome timestamps to human readable date & Unix time in Ruby/Rails

Convert WebKit/Chrome timestamps to human readable date & Unix time in Ruby/Rails.

This timestamp format is used in web browsers such as chrome & safari, So how we convert human readable date & Unix time in Ruby/Rails.

Chrome’s base time is 01/01/1601 00:00:00. To calculate local time, Chrome time has to be converted to seconds by dividing by one million, and then the seconds differential between 01/01/1601 00:00:00 and 01/01/1970 00:00:00 must be subtracted.

Q. What is the significance of January 1, 1601 00:00:00?

A. The Gregorian calendar operates on a 400-year cycle, and 1601 is the first year of the cycle that was active at the time Windows NT was being designed. In other words, it was chosen to make the math come out nicely. Reference.

Now we will declare a method which can convert this WebKit/Chrome timestamps to human readable date & Unix time with Ruby/Rails

Now call this with timestamps data

here we go!

WebKit/Chrome Timestamp

Fool Dev

I didn't get trained by the school system like other kids, and when I did concentrate on learning, my mind was cluttered and locked by the programming of the system. © Huey Newton