mktime

.mktime and .strftime help returning wrong day of week

╄→гoц情女王★ 提交于 2019-12-12 01:03:39
问题 Before I get yelled at I am not a php coder and I have searched vary heavily to try and figure this out without luck here and on the net. I have seen some things, but just don't have enough understanding to apply with my limited understanding. The php code was developed by someone who has vanished, so not supporting and I have one little bug I need to try and clean up and why a html/css guy is even trying to figure this out without much luck. So appreciate groups help and patience as well as

php date('d') calculates same output for two consecutive days

旧街凉风 提交于 2019-12-11 12:33:18
问题 I'm building a calendar through PHP and the way I'm doing this results on some days being written twice. I replicated the behaviour in this little script: <?php // // define a date to start from // $d = 26; $m = 10; $y = 2013; date_default_timezone_set('CET'); $time = mktime(0, 0, 0, $m, $d, $y); // // calculate 10 years // for($i=0;$i<3650;$i++){ $tomorrowTime = $time + (60 * 60 * 24); // // echo date if the next day has the same date('d') result // if(date('d',$time)==date('d',$tomorrowTime

C++ mktime changes value of my tm_struct

浪子不回头ぞ 提交于 2019-12-11 10:59:38
问题 I read bMonth from user; time_t timestamp = time(NULL); tm* birthday = localtime(&timestamp); birthday->tm_mon = bMonth-1; // now the tm_mon is set corectly time_t birthStamp = mktime(birthday); // now the tm_mon is 0 Why mktime changes the values? 回答1: mktime A call to this function automatically adjusts the values of the members of timeptr if they are off-range or -in the case of tm_wday and tm_yday- if they have values that do not match the date described by the other members. 来源: https:/

why strotime returns negative value in php?

送分小仙女□ 提交于 2019-12-11 10:50:36
问题 I am using strtotime to convert a date to a unixtime stamp. Year, date and day comes as different values to code and I am using the below code to produce the timestamp. $year = '1961'; $month = '2'; $day = '15'; $date = $year."-".$month."-".$day; echo strtotime($date); The above code prints : -27648000 for me. If the year is above 1970 it prints out positive results. I am still learning with the timestamp, if any one can help me out. The main aim is to convert a date to unix timestamp. The

mktime shows inconsistent output

谁说胖子不能爱 提交于 2019-12-11 06:44:29
问题 While trying to write code which returns 24 hours less than a given time, mktime() shows inconsistent output. I calculate it similar to this: current_time(GMT) - 86400 which should return the right value. All we need to do is calculate based on the input time; we used mktime() to change the time and get the GMT time and then do the regular calculation. I included my code below. #include <stdio.h> #include <time.h> int main() { time_t currentTime, tempTime; struct tm *localTime; time(

is mktime() using date() daylight saving aware?

a 夏天 提交于 2019-12-11 05:26:31
问题 I've read through a few questions about this here on s.o. and none seem to ask or answer the question very bluntly: $ts_today = mktime( 0, 0, 0, date('m'), date('d'), date('Y') ); is this daylight saving aware? if not, how do i make mktime() daylight saving aware? 回答1: ~There's plenty of discussion of this on the PHP site itself, and some useful examples. In short, newer versions of PHP take account of DST as part of the timezone handling functionality 回答2: The last argument specifies whether

System call mktime ignores tm_isdst flag

人盡茶涼 提交于 2019-12-11 04:29:20
问题 another one question regarding mktime and DST Linux, Ubuntu, time zone is set to Europe/Berlin i.e. current time is CEST: >date Mon Aug 22 16:08:10 CEST 2016 >date --utc Mon Aug 22 14:08:14 UTC 2016 everything okay so far. Now I try to run the following code: #include <stdio.h> #include <time.h> int main() { struct tm tm = {0}; int secs; tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 12; tm.tm_mon = 9 - 1; tm.tm_mday = 30; tm.tm_year = 2016 - 1900; tm.tm_isdst = 0; secs = mktime(&tm); printf("%i

How would I fix the last day of the month errors that result with this php code?

十年热恋 提交于 2019-12-10 18:50:05
问题 The code below is what I'm using for a website menu which moves the link for the current month's page to the top of the link list on the change of the month. But this fails on the 31st of some months, such as April; I get two links to the same month for most of the links. I've read through the issues with the way php generates dates, but can't figure out how to change this code. Anyone php Ph.D's want to take a stab at it? Thanks <?php $month1 = (date('F', mktime(date('H'), date('i'), date('s

valgrind complaining about __mktime - is that my fault?

大憨熊 提交于 2019-12-10 16:39:35
问题 For the first time (in my new dev environment) I'm seeing valgrind complain about mktime, but I'm not sure if this is a bug in the libc library, valgrind, or my code. I'll start with the error (below) - is this enough info to explain the cause? ==3682== at 0x38ACE9A505: __mktime_internal (in /lib64/libc-2.12.so) ==3682== by 0x4D66F7: ??? ==3682== by 0x4D7611: ??? ==3682== by 0x4D23CD: ??? ==3682== by 0x4D175B: ??? ==3682== by 0x38ACE1ECDC: (below main) (in /lib64/libc-2.12.so) ==3682==

Confusing behaviour of mktime on Linux?

坚强是说给别人听的谎言 提交于 2019-12-07 05:19:43
问题 I am using the mktime(struct tm*) function in Suse 10. Now, I am noticing some strange behaviour when daylight saving time is enabled. Let's say I have enabled daylight saving time to begin on Sep 15 at 18:10 and the daylight correction is for 30 minutes. Now, when I call mktime with tm structure having the date as Sep 15 18:10 and tm_isdst is set to 0, then I get back the same values in the tm structure only with the tm_isdst set to 1. But, if the pass the date as Sep 15 18:10 with tm_isdst