Home > Web Front-end > HTML Tutorial > Atitit. Lunar calendar date calculation based on timestamp

Atitit. Lunar calendar date calculation based on timestamp

WBOY
Release: 2016-08-15 16:49:46
Original
1549 people have browsed it

Atitit.Lunar calendar calendar date calculation based on timestamp

1. Lunar calendarxxThe size and month of the year are queried according to the perpetual calendar1

2. lunar calendarxxyear1month1day timestamp gets1

3. Calculate the correspondence table between the timestamp of the current year and the lunar date. The timestamp is key and the date is val1

4. Get the lunar date based on the obtained timestamp2

1. Lunar calendarxxThe size and month of the year are queried according to the perpetual calendar

2006 The month of the year13689, 11,12

The month of leap month none

Little golden month2457,10

2. Get the timestamp of lunarxxyear1month1day

Lunar calendar2016year1month1day, converted to Gregorian calendar 2016-02-08 , get the timestamp (sec)

The timestamp of

2016-02-08 00:00:01 is: 1454860801

// Get the timestamp in a certain time format

var stringTime = "2016-02-08 00:00:01";

var timestamp2 = Date.parse(new Date(stringTime));

timestamp2 = timestamp2 / 1000;

The timestamp of

//2014-07-10 10:21:12 is: 1404958872

console.log(stringTime + "The timestamp of is: " + timestamp2);

Time stamp accurate to day 16838.66667824074 day

Author:: ★(attilax)>>> nickname:老Wow’s Claw ( Full name: Attilax Akbar Al Rapanui AttilaxAkbarAlRapa Nui)Chinese name: Ailong, EMAIL:1466519819@qq.com

Please indicate the source when reprinting: http://www.cnblogs.com/attilax/

3. Calculate the correspondence table between the timestamp of the current year and the lunar date. The timestamp is key and the date is val

var base=16838;

var lit_a=[2,4,5,7,10];

var map={};

var map_abs={};

var offset=1;

for(var i=1;i<=12;i++)

{

for(var j=1;j<=30;j++)

{

map[offset]=i+"-"+j;

map_abs[offset+base]=i+"-"+j;

console.log(" offset:"+offset+" date:"+map[offset]);

offset++;

if(lit_a.indexOf(i)>-1) //if mon is litt mon

{

if(j>=29)

break;

}

}

}

4. Get the lunar date based on the obtained timestamp

function getNowDateTmstmp()

{

var timestamp = Date.parse(new Date());

timestamp=timestamp/(3600*24*1000);

return Math.floor(timestamp);

}

var nowStmp_date=getNowDateTmstmp();

alert( map_abs[nowStmp_date]);

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template