
郑先森灬
time()在PHP中是得到一个数字,这个数字表示从1970-01-01到现在共走了多少秒,很奇怪吧
不过这样方便计算,
要找出前一天的时间就是 time()-606024;
要找出前一年的时间就是 time()606024365
那么如何把这个数字换成日期格式呢,就要用到date函数了
$t=time();
echo date("Y-m-d H:i:s",$t);
第一个参数的格式分别表示:
a - "am" 或是 "pm"
A - "AM" 或是 "PM"
d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"
D - 星期几,三个英文字母; 如: "Fri"
F - 月份,英文全名; 如: "January"
h - 12 小时制的小时; 如: "01" 至 "12"
H - 24 小时制的小时; 如: "00" 至 "23"
g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"
G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"
i - 分钟; 如: "00" 至 "59"
j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"
l - 星期几,英文全名; 如: "Friday"
m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"
n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"
M - 月份,三个英文字母; 如: "Jan"
s - 秒; 如: "00" 至 "59"
S - 字尾加英文序数,二个英文字母; 如: "th","nd"
t - 指定月份的天数; 如: "28" 至 "31"
U - 总秒数
w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六)
Y - 年,四位数字; 如: "1999"
y - 年,二位数字; 如: "99"
z - 一年中的第几天; 如: "0" 至 "365"
其它不在上列的字符则直接列出该字符
下面是实际使用方式:
<?php
echo date("Ymd",strtotime("now")), "\n";
echo date("Ymd",strtotime("-1 week Monday")), "\n";
echo date("Ymd",strtotime("-1 week Sunday")), "\n";
echo date("Ymd",strtotime("+0 week Monday")), "\n";
echo date("Ymd",strtotime("+0 week Sunday")), "\n";
echo "*********第几个月:";
echo date('n');
echo "*********本周周几:";
echo date("w");
echo "*********本月天数:";
echo date("t");
echo "*********";
echo '<br>上周起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y"))),"\n";
echo '<br>本周起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))),"\n";
//从第几周找出该周的开始日期和结束日期
$dayNumber = date('W') * 7;
$weekDayNumber = date("w", mktime(0, 0, 0, 1, $dayNumber, date("Y")));//当前周的第几天
$startNumber = $dayNumber - $weekDayNumber;
echo date("Y-m-d", mktime(0, 0, 0, 1, $startNumber + 1, date("Y")));//开始日期
echo date("Y-m-d", mktime(0, 0, 0, 1, $startNumber + 7, date("Y")));//结束日期
echo '<br>上月起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y"))),"\n";
echo '<br>本月起始时间:<br>';
echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y"))),"\n";
echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))),"\n";
$season = ceil((date('n'))/3);//当月是第几季度
echo '<br>本季度起始时间:<br>';
echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))),"\n";
echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))),"\n";
$season = ceil((date('n'))/3)-1;//上季度是第几季度
echo '<br>上季度起始时间:<br>';
echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))),"\n";
echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))),"\n";
?>
输出结果
EYblog - Powered by Eyblog
https://akxdz.com/index.php/archives/64/(转载时请注明本文出处及文章链接)
buying ed pills online erectile dysfunction medicines men's ed pills
anti fungal pills without prescription cat antibiotics without pet prescription canadian drug pharmacy
buy finasteride generic finasteride for sale purchase finasteride without a prescription
prescription drugs canada buy online best online canadian pharmacy pet meds without vet prescription canada
prednisone 5mg capsules generic prednisone 3000mg prednisone
buy cialis no prescription overnight cialis usa online cialis 30 mg dose
ed cure ed meds online without doctor prescription drugs prices
buy cialis on line buy cialis without doctor prescription cialis paypal payment canada
Вам 101 726 р
Подробнее по ссылке: https://forms.yandex.ru/u/7auj02l94rw254nv9ari/success/?AAAAAakxdz.comBBBBB
buy stromectol 6 mg online stromectol drops stromectol drug
stromectol tablets stromectol buy stromectol side effects
can you buy stromectol over the counter ivermectin for dogs tractor supply ivermectin candida
buy cialis singapore cialis tablets australia generic cialis uk online
ivermectin dispersible tablets buy ivermectin cream buy ivermectin online
psychological ed treatment best online pharmacy viagra without a doctor prescription
best online pharmacy non prescription ed drugs ed treatment review
canadian online drugs online canadian pharmacy ed medicine
doxycycline online uk 100 doxycycline doxycycline 100
how much is amoxicillin prescription buying amoxicillin in mexico how to buy amoxycillin
amoxicillin 500 mg online amoxicillin over the counter in canada amoxicillin capsule 500mg price
doxycycline 100mg acne how to order doxycycline doxycycline 100mg dogs
canada buy prednisone online 10 mg prednisone tablets cortisol prednisone
54 prednisone 20 mg prednisone buy 10 mg prednisone
buy amoxicillin buy cheap amoxicillin buy cheap amoxicillin
how many 5mg cialis can i take at once 20mg cialis generic cialis efectos secundarios
cialis sublingual cialis for sale over the counter canada cialis for sale
stromectol cvs can you buy stromectol over the counter herbal equivalent to ivermectin
generic cialis 10mg 30 pills cialis paypal payment canada generic cialis in canada
comparison of 10 mg cialis price can i take cialis with daxpoteine rx online cialis
does viagra make you bigger or just hard what happens if you take viagra and you don't need it how to tell if a man is taking viagra
https://cutt.ly/NDOL9An# can i take 200mg of viagra
best place to buy viagra online forum how to tell if a man is taking viagra how much does viagra cost without insurance
cialis hk cialis time to work free trial cialis
what exactly does viagra do? non prescription viagra alternative over the counter viagra substitute walmart
chewable viagra soft tabs what does viagra look like best way to take viagra
doxycycline online without prescription oral doxycycline buy doxycycline 100mg online usa
buy cheap generic viagra what is better viagra or levitra viagra for sale in south africa
doxycycline pharmacy uk doxycycline capsules india purchase doxycycline online uk
ivermectin scabies buy online ivermectin pigeon ivermectin injectable for horses
ivermectin 1.87 dosage for humans what does ivermectin treat in dogs ivermectin lung cancer
ivermectin sheep drench dosage how fast does ivermectin work ivermectin dose for humans
cialis overnight delivery cialis vs viagra cialis only
cialis nz cialis cialis 30 day free trial
plaquenil covid hydroxychloroquine 200 mg hcq over the counter
paxlovid patient fact sheet paxlovid prix covid antiviral pills
hydroxychloroquine 400 mg buy online hcq for sale plaquenil and covid
paxlovid canada paxlovid clinical trial paxlovid drug interactions list
high blood pressure viagra how to make homemade viagra do you need prescription for viagra
how much does the military spend on viagra generic viagra without prescription difference between cialis and viagra
buy doxycycline online buy doxycycline online uk - buy doxycycline online without prescription
https://doxycyline1st.com/# doxycycline without prescription
100mg doxycycline where can i get doxycycline - generic doxycycline
https://doxycyline1st.com/# generic for doxycycline
how to order doxycycline doxycycline 500mg - doxycycline 200 mg
https://doxycyline1st.com/# doxycycline mono
clomid cost clomid tablet - clomid dosage
https://clomiphene1st.com/# clomid online purchase
https://stromectolis.com/# stromectol coronavirus
https://stromectolis.com/# ivermectin gel
https://stromectolis.com/# stromectol where to buy
https://stromectolis.com/# ivermectin 3mg tablets
https://stromectolis.com/# stromectol uk
https://stromectolis.com/# stromectol online canada
https://stromectolis.com/# ivermectin new zealand
https://stromectolis.com/# ivermectin uk coronavirus
ivermectin pills: ivermectin - ivermectin tablets
https://stromectolst.com/# ivermectin syrup
stromectol where to buy stromectol for sale stromectol 12mg
stromectol usa: buy stromectol - stromectol for humans
http://stromectolst.com/# ivermectin nz
stromectol 3 mg price ivermectin ivermectin lice oral
cheap paxlovid where can i get paxlovid buy paxlovid
https://myalliancehealthcare.online/ buy molnupiravir
buy molnupiravir online molnupiravir where can i get molnupiravir
cheap paxlovid paxlovid purchase paxlovid
https://apollobgshospitalsmysore.online/ paxlovid for sale
cost of molnupiravir buy molnupiravir molnupiravir india
paxlovid for sale buy paxlovid paxlovid price
https://myalliancehealthcare.online/ molnupiravir
buy molnupiravir molnupiravir cost of molnupiravir
best non prescription ed pills anti fungal pills without prescription canadian drugs online
https://without-prescription-online.com/ canadian online drugs
meds online without doctor prescription buy prescription drugs without doctor pet meds without vet prescription
the canadian drugstore canadian drug legal to buy prescription drugs without prescription
https://without-prescription-online.online/ pet antibiotics without vet prescription
prescription without a doctor's prescription prescription drugs without prior prescription canadian drugs
cvs prescription prices without insurance canadian drugs online ed meds online without doctor prescription
https://without-prescription-online.online/ canadian online pharmacy
mexican pharmacy without prescription canadian online pharmacy pet antibiotics without vet prescription
where can you buy zithromax zithromax online paypal zithromax 250 mg australia
https://azithromycin1st.com/ zithromax 250 mg australia
buy zithromax 1000 mg online where to get zithromax zithromax cost australia
buy zithromax online zithromax 500 zithromax prescription in canada
https://azithromycin1st.com/ zithromax order online uk
buy azithromycin zithromax zithromax price canada buy zithromax 1000mg online
zithromax online generic zithromax over the counter can i buy zithromax over the counter
https://azithromycin1st.com/ zithromax for sale us
can you buy zithromax over the counter in mexico zithromax antibiotic zithromax capsules
buy zithromax 1000mg online zithromax how to get zithromax over the counter
https://azithromycin1st.com/ zithromax for sale usa
zithromax capsules 250mg where to get zithromax over the counter zithromax online usa
ivermectin price canada stromectol for humans for sale - cost of ivermectin
http://stromectolabc.online/ ivermectin lotion
ivermectin pill cost stromectol stromectol tablet 3 mg