Get next/previous ISO week and year in PHP

自闭症网瘾萝莉.ら 提交于 2019-11-28 09:47:44

问题


I need a function that takes an ISO week and an ISO year as parameter and returns the next ISO week and year (and a function that returns the previous ISO week/year).


回答1:


So answer for 4 day so i give it a shot:

<?php

// Start with Timstamp 0, else the seconds might be off
$x = new DateTime("1970-01-01 00:00:00");
$x->setISODate(2010, 2);
echo $x->format("Y-m-d H:i:s"); // 2010-01-11 00:00:00

$x->modify("+1 week");

echo $x->format("Y-m-d H:i:s"); // 2010-01-18 00:00:00

// Now for the next ISO Week
echo $x->format("Y W"); // 2010 03

Hope that helps, else let me know :)



来源:https://stackoverflow.com/questions/3625484/get-next-previous-iso-week-and-year-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!