使用php获取下一个第15天和/或第30天的日期?(Get the date of the next 15th and/or 30th day with php?)
我要求获取当前日期即将到来的下个月的15日和30日的日期。 (如果二月在范围内,当然必须是28/29)。
我可以使用mktime / strtotime或者使用其他方法吗?
我得到了这个,但当然这只是为了这个和下个月的最后一天。 我需要即将到来的15日和30日。
$cuota1 = date('t-m-Y', strtotime('+15 days')); return $cuota1; $cuota2 = date('t-m-Y', strtotime('+30 days')); return $cuota2; $cuota3 = date('t-m-Y', strtotime('+45 days')); return $cuota3;
提前致谢。
I require to get the dates of the upcoming 15th and 30ths of the next months as for the current date. (If February is within range it must be 28/29th of course).
Can I do this using mktime/strtotime or maybe using another method?
I got this but of course this is for only get the last day of this and next month. I need the upcoming 15ths and 30ths instead.
$cuota1 = date('t-m-Y', strtotime('+15 days')); return $cuota1; $cuota2 = date('t-m-Y', strtotime('+30 days')); return $cuota2; $cuota3 = date('t-m-Y', strtotime('+45 days')); return $cuota3;
Thanks in advance.
原文:https://stackoverflow.com/questions/33525932
更新时间:2022-02-21 17:02
最满意答案
这是一种方法:
>>> s = '0xFFFF00' >>> i = int(s, 16) >>> print i
This is one way to do it:
>>> s = '0xFFFF00' >>> i = int(s, 16) >>> print i
相关问答
更多-
您不能将字符串转换为十六进制,只能使用%016x格式化%016x 。 您可以通过解析"123456"来解决此问题: String.format("%016x", Integer.parseInt("123456")); You cannot convert a string to hexadecimal like that, only a number can be formatted with %016x. You can fix this by parsing "123456": String.for ...
-
您应该使用%x格式说明符而不是%s来读取您的值。 这将以十六进制整数读取数据。 例如,如果您的文件如下所示: ff3c 5a cb2d 然后你可以读取这样的3个值: int a, b, c; fscanf(fp, "%x %x %x", &a, &b, &c); // a = 0xff3c, b = 0x5a, c = 0xcb2d You should use the %x format specifier instead of %s to read your values. This will rea ...
-
如何将包含十六进制对的字符串转换为字节?(How do I convert a string containing a hexadecimal pair to a byte?)[2024-01-14]
到目前为止发布的选项的替代方案: byte b = Convert.ToByte(text, 16); 请注意,如果text为空,这将返回0; 这可能是也可能不是你想要的结果。 An alternative to the options posted so far: byte b = Convert.ToByte(text, 16); Note that this will return 0 if text is null; that may or may not be the result you w ... -
从这个C ++转义序列参考 : 十六进制转义序列没有长度限制,并且终止于不是有效的十六进制数字的第一个字符。 所以没有任何解决方法,编译器将读取的数字没有限制。 请注意, 相应的C引用表示同样的事情。 From this C++ escape sequence reference: Hexadecimal escape sequences have no length limit and terminate at the first character that is not a valid hexadec ...
-
假设你正试图将你的string转换为int : var i = Int32.Parse("FF", System.Globalization.NumberStyles.HexNumber) 但是,您的示例1847504890不适合int 。 改用更长的类型。 var i = Int64.Parse("1847504890", System.Globalization.NumberStyles.HexNumber) Assuming you are trying to convert your strin ...
-
将十六进制的字符串rep转换为实际的十六进制[duplicate](convert string rep of hexadecimal into actual hexadecimal [duplicate])[2023-02-16]
这是一种方法: >>> s = '0xFFFF00' >>> i = int(s, 16) >>> print i This is one way to do it: >>> s = '0xFFFF00' >>> i = int(s, 16) >>> print i -
有没有快速的方法将List
转换为十六进制字符串?(Is there any fast way to convert List [2022-11-02]to hex string? [duplicate]) 有很多方法可以做到这一点,但这个可能适合你 ListhexStrings = TRIGGER_POL.Select(b => BitConverter.ToString(new byte[]{b})).ToList(); 或者如果你只想要1个字符串 string hex = BitConverter.ToString(TRIGGER_POL.ToArray()); There are losts of ways to do this but this one may work for ... -
十六进制值字符串到varbinary SQL Server 2008 [重复](Hexadecimal valued string to varbinary SQL Server 2008 [duplicate])[2023-08-18]
没有内置功能来执行此操作。 在C#中编写流功能来完成它将是微不足道的(读取2个字符,发出一个字节)。 您可以使用SQLCLR函数在引擎内执行此操作,也可以在客户端执行此操作。 如果输入很大,可以说在客户端更好,以避免内存过载。 这是流转换的一个例子(没有优化,但强调了不将string转换为byte[]的重要性): namespace hex2bin { class Program { public static void hex2bin(TextReader sin, Bin ... -
CPP读取0x0A作为字符串而不是十六进制[重复](CPP reading 0x0A as string instead of hexadecimal [duplicate])[2021-12-17]
您可以使用带有std::hex的istringstream将十六进制字符串转换为数值: std::istringstream stream("0x0A"); int val = 0; stream >> std::hex >> val; std::cout >> val; // prints "10" You can use an istringstream with std::hex to convert hex strings to numeric values: std::istringstream ... -
将十六进制字符串解析为二进制字符的最佳方法[复制](Best way to parse hexadecimal string into binary char [duplicate])[2022-03-29]
这个怎么样: void readStr(const std::string& str, unsigned char* output) { for (size_t s = 0; s < str.size() ; s+= 2){ std::string twoChars = str.substr(s,2); // Read two chars unsigned char c = (unsigned char)std::stoi( twoChars,0,16); // Tra ...