kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

unix时间戳, excel date, 儒略日julian date

UNIX时间戳

https://www.cnblogs.com/xifengyeluo/p/8143059.html

Unix时间戳(英文为Unix epoch, Unix time, POSIX time 或 Unix timestamp)

是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒。

UNIX时间戳的0按照ISO 8601规范为 :1970-01-01T00:00:00Z.

一个小时表示为UNIX时间戳格式为:3600秒;一天表示为UNIX时间戳为86400秒,闰秒不计算。

在大多数的UNIX系统中UNIX时间戳存储为32位,这样会引发2038年问题或Y2038。

excel date

https://blog.csdn.net/luoluoyu2013/article/details/127750570

excel:

1
2
3
日期转时间戳:B1=INT((A1-70*365-19)*86400-8*3600)*1000

时间戳转日期:A1=TEXT((B1/1000+8*3600)/86400+70*365+19,"yyyy-mm-dd hh:mm:ss")

是从 1899-12-30 开始的天数 ???

1
2
3
4
5
echo date('Y-m-d', strtotime("1899-12-30 +45506 days"));

$d1 = new DateTime('1970-01-01');
$d0 = new DateTime('1899-12-30');
echo $d1->diff($d0)->format("%a days");
1
2
2024-08-02
25569 days

儒略日 (Julian Date)

儒略日(Julian day,JD)是指由公元前4713年1月1日,协调世界时中午12时开始所经过的天数,多为天文学家采用,用以作为天文学的单一历法,把不同历法的年表统一起来。

儒略日(Julian Date)的简化: 由于儒略日数字位数太多,国际天文学联合会于1973年采用简化儒略日(MJD),其定义为 MJD = JD - 2400000.5。MJD相应的起点是1858年11月17日世界时0时。 例如1979年10月1日零时儒略日数为2,444,147.5。天文年历附表载有各年每月零日世界时12时的儒略日数。

1
2
3
4
5
<?php
    echo gregoriantojd(10, 1, 1979) - 0.5, "\n";
    echo gregoriantojd(10, 1, 1979) - 0.5 - 2400000.5, "\n";

    echo jdtogregorian(2444147.5 + 0.5), "\n";
1
2
3
2444147.5
44147
10/1/1979

https://blog.sina.com.cn/s/blog_65d6476a0101k54y.html

&times被替换成x

https://www.cnblogs.com/wobeinianqing/p/7067547.html

https://www.cnblogs.com/gyfluck/p/12558079.html

1
2
3
http://www.test.com/index.php?id=1×tamp=1584947618&age=10

http://www.test.com/index.php?id=1&timestamp=1584947618&age=10

htmlspecialchars

使用htmlspecialchars()函数,把预定义的字符 转成 HTML 实体

1
2
3
echo htmlspecialchars($url);

http://www.test.com/index.php?id=1&timestamp=1584947618&age=10

手动转换

No.文字表記10進表記16進表記文字 Comment
001 &quot; &#34; &#x22; """   quotation mark = APL quote
002 &amp; &#38; &#x26; "&"   ampersand
003 &lt; &#60; &#x3C; "<"   less-than sign
004 &gt; &#62; &#x3E; ">"   greater-than sign
005 &nbsp; &#160; &#xA0; " "   no-break space = non-breaking space
char glyphHTML tag
  &nbsp;
¡ &iexcl;
¢ &cent;
£ &pound;
¤ &curren;
¥ &yen;
¦ &brvbar;
§ &sect;
¨ &uml;
© &copy;
ª &ordf;
« &laquo;
¬ &not;
  &shy;
® &reg;
¯ &macr;
° &deg;
± &plusmn;
² &sup2;
³ &sup3;
´ &acute;
µ &micro;
&para;
· &middot;
¸ &cedil;
¹ &sup1;
º &ordm;
» &raquo;
¼ &frac14;
½ &frac12;
¾ &frac34;
¿ &iquest;
À &Agrave;
Á &Aacute;
 &Acirc;
à &Atilde;
Ä &Auml;
Å &Aring;
Æ &AElig;
Ç &Ccedil;
È &Egrave;
É &Eacute;
Ê &Ecirc;
Ë &Euml;
Ì &Igrave;
Í &Iacute;
Î &Icirc;
Ï &Iuml;
Ð &ETH;
Ñ &Ntilde;
Ò &Ograve;
Ó &Oacute;
Ô &Ocirc;
Õ &Otilde;
Ö &Ouml;
× &times;
Ø &Oslash;
Ù &Ugrave;
Ú &Uacute;
Û &Ucirc;
Ü &Uuml;
Ý &Yacute;
Þ &THORN;
ß &szlig;
à &agrave;
á &aacute;
â &acirc;
ã &atilde;
ä &auml;
å &aring;
æ &aelig;
ç &ccedil;
è &egrave;
é &eacute;
ê &ecirc;
ë &euml;
ì &igrave;
í &iacute;
î &icirc;
ï &iuml;
ð &eth;
ñ &ntilde;
ò &ograve;
ó &oacute;
ô &ocirc;
õ &otilde;
ö &ouml;
÷ &divide;
ø &oslash;
ù &ugrave;
ú &uacute;
û &ucirc;
ü &uuml;
ý &yacute;
þ &thorn;
ÿ &yuml;

Math symbols

Latin Extended-B
char glyphHTML tag
ƒ &fnof;
 
Arrows
char glyphHTML tag
← &larr;
↑ &uarr;
→ &rarr;
↓ &darr;
↔ &harr;
↵ &crarr;
⇐ &lArr;
⇑ &uArr;
⇒ &rArr;
⇓ &dArr;
⇔ &hArr;
 
Mathematical Operators
char glyphHTML tag
∀ &forall;
∂ &part;
∃ &exist;
∅ &empty;
∇ &nabla;
∈ &isin;
∉ &notin;
∋ &ni;
∏ &prod;
∑ &sum;
− &minus;
∗ &lowast;
√ &radic;
∝ &prop;
∞ &infin;
∠ &ang;
∧ &and;
∨ &or;
∩ &cap;
∪ &cup;
∫ &int;
∴ &there4;
∼ &sim;
≅ &cong;
≈ &asymp;
≠ &ne;
≡ &equiv;
≤ &le;
≥ &ge;
⊂ &sub;
⊃ &sup;
⊄ &nsub;
⊆ &sube;
⊇ &supe;
⊕ &oplus;
⊗ &otimes;
⊥ &perp;
⋅ &sdot;
 
General Punctuation
char glyphHTML tag
• &bull;
… &hellip;
′ &prime;
″ &Prime;
‾ &oline;
⁄ &frasl;
 
Miscellaneous Technical
char glyphHTML tag
⌈ &lceil;
⌉ &rceil;
⌊ &lfloor;
⌋ &rfloor;
⟨ &lang;
⟩ &rang;
 
Geometric Shapes
char glyphHTML tag
◊ &loz;
 
Miscellaneous Symbols
char glyphHTML tag
♠ &spades;
♣ &clubs;
♥ &hearts;
♦ &diams;

 

Letterlike Symbols
char glyphHTML tag
℘ &weierp;
ℑ &image;
ℜ &real;
™ &trade;
ℵ &alefsym;
 
Greek
char glyphHTML tag
Α &Alpha;
Β &Beta;
Γ &Gamma;
Δ &Delta;
Ε &Epsilon;
Ζ &Zeta;
Η &Eta;
Θ &Theta;
Ι &Iota;
Κ &Kappa;
Λ &Lambda;
Μ &Mu;
Ν &Nu;
Ξ &Xi;
Ο &Omicron;
Π &Pi;
Ρ &Rho;
Σ &Sigma;
Τ &Tau;
Υ &Upsilon;
Φ &Phi;
Χ &Chi;
Ψ &Psi;
Ω &Omega;
α &alpha;
β &beta;
γ &gamma;
δ &delta;
ε &epsilon;
ζ &zeta;
η &eta;
θ &theta;
ι &iota;
κ &kappa;
λ &lambda;
μ &mu;
ν &nu;
ξ &xi;
ο &omicron;
π &pi;
ρ &rho;
ς &sigmaf;
σ &sigma;
τ &tau;
υ &upsilon;
φ &phi;
χ &chi;
ψ &psi;
ω &omega;
ϑ &thetasym;
ϒ &upsih;
ϖ &piv;

localtime函数

https://www.php.cn/faq/631443.html

localtime函数的原型是

1
struct tm *localtime(const time_t *timep);

这个函数接受一个指向 time_t 类型的指针作为参数,返回一个指向structtm类型的指针,表示本地时间。

localtime是一个常用的函数,它可以将一个时间戳转换为一个本地时间的结构体。

time_t 是一个表示时间戳的数据类型,它通常是一个长整型(long int),表示自 1970 年 1 月 1 日以来经过的秒数。structtm 是一个表示日期和时间的结构体,它包含了年、月、日、时、分、秒等信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <time.h>

int main()
{
	time_t timestamp = time(NULL);            // 获取当前的时间戳
	structtm *local_time = localtime(timestamp);  // 将时间戳转换为本地时间

	// 输出本地时间的各个字段
	printf("Year: %d\n", local_time->tm_year + 1900);  // 加1900是为了得到实际的年份
	printf("Month: %d\n", local_time->tm_mon + 1);     // 加1是为了得到实际的月份(1-12月)
	printf("Day: %d\n", local_time->tm_mday);
	printf("Hour: %d\n", local_time->tm_hour);
	printf("Minute: %d\n", local_time->tm_min);
	printf("Second: %d\n", local_time->tm_sec);
	printf("Day of week: %d\n", local_time->tm_wday);  // 周几,从0开始计数,0表示星期一,6表示星期日
	printf("Day of year: %d\n", local_time->tm_yday);  // 一年中的第几天,从0开始计数,0表示1月1日,365表示12月31日
	printf("Zone: %s\n", asctime(local_time));        // 输出本地时间的字符串表示,例如:"Wed Jun 30 21:49:08 1993\n"

	return 0;
}