Traditional Culture Encyclopedia - Almanac inquiry - How to calculate the timestamp in JS is several months ago? For example: 1577808000
How to calculate the timestamp in JS is several months ago? For example: 1577808000
var t = 1577808000; //Timestamp (seconds)
Var ot = new date (t *1000); //Become a time object (the timestamp of js is milliseconds)
var oy = ot . get full year(); //year
var om = ot . getmonth()+ 1; //month
Var TT = new date (); //Today
var ty = TT . get full year(); //Today's year
var TM = TT . getmonth()+ 1; //Today's month
var GM =(ty-oy)* 12+(TM-om); //A few months later
alert(ot . tolocaledatestring()+“Today“+GM+“Months“);
- Previous article:There are zodiac signs in the yellow calendar.
- Next article:Zodiac auspicious day 2018101October 25th Gregorian calendar query
- Related articles
- Gregorian calendar 20191February 15.
- Uncle Jiang said Feng Shui: Ten problems to pay attention to when moving.
- Male snake 1989 September 1 female sheep 199 1 February 15 We want to get married in April. Please help us choose a good day. Thank you.
- Zodiac auspicious day 2065438+April 25, 2007 Gregorian calendar query
- List of days suitable for obtaining certificates in 2023. Free inquiry on wedding auspicious day in the Year of Rabbit?
- It is suggested that July 2023 is a good day for engagement.
- Gregorian calendar1991July 3, and may 1992, when is a good day for girls and boys to get married?
- Yellow whale
- Dreaming that I couldn't find my way.
- I dreamed that I was holding the old lady's hand.