Questions tagged [mktime]

mktime is a function that returns the time since the UNIX epoch from a given date and time. Found in C and PHP.

Reference for the C function: https://en.cppreference.com/w/c/chrono/mktime

Reference for the PHP function: https://php.net/manual/en/function.mktime.php

308 questions
2
votes
3 answers

C++ mktime and DST

I am processing stored dates and times. I store them in a file in GMT in a string format (i.e. DDMMYYYYHHMMSS). When a client queries, I convert this string to a struct tm, then convert it to seconds using mktime. I do this to check for invalid…
user2409054
  • 131
  • 1
  • 7
2
votes
1 answer

Sometimes different results of mktime in windows and in linux

Here is the function time_t time_from_string(const char* timestr) { if (!timestr) return 0; struct tm t1; memset(&t1, 0, sizeof(t1)); int nfields = sscanf(timestr, "%04d:%02d:%02d %02d:%02d:%02d", …
wl2776
  • 4,099
  • 4
  • 35
  • 77
2
votes
2 answers

Time of day script

I have a small script that depending on the time and day; I would like it to output different things: = "16:30") { $tomorrow = mktime(0, 0, 0, date("m") ,…
Bift
  • 23
  • 1
  • 4
2
votes
1 answer

php echo week number counting days out of a full year

This is a working demo of my script : http://phpfiddle.org/main/code/f9b-cmr What i would like to do is display the day then the amount of days that day has appeared in the year and then the total of times it will appear in the whole year. example…
Daisy Oopsy
  • 155
  • 9
2
votes
3 answers

Python not executing on time.mktime condition in if statement

I have a small script I was going to use to execute a system command at a specified time ("commandTime") and then exit a specified time afterwards ("stopTime"). However, when I run the script it more often than not will never execute the command…
2
votes
3 answers

How to retain millisecond information while using mktime in awk?

I have a date string of the format 2012-12-20T01:16:02.05 and i want to convert to the format 2011-12-20-01.16.02.050000 Currently i am doing it as follows format = "%F-%H.%M.%S.%N" split(stringinput,input,"T");…
Priya Ranjan
  • 21
  • 1
  • 2
2
votes
3 answers

Get number of days since epoch in C++ (cross platform)

How can i get count of days since epoch in C++, i know that i should use mktime function, but i cant understand how to implement it Thanks!
Breakdown
  • 1,035
  • 4
  • 16
  • 26
2
votes
3 answers

PHP: How to create a timestamp from pattern H:i (17:45)?

my current code: Now I've a form with two fields: date and time, separated.
Mr. B.
  • 8,041
  • 14
  • 67
  • 117
2
votes
1 answer

mktime conversion

I wanted to calculate the time difference for a GMT time and current time. For this I am converting tm time (which is in GMT) to time_t format using mktime. and current time using time() api. struct tm = x; time_t t1, t2; time(&t1); /* here x …
user1345697
  • 405
  • 2
  • 5
  • 15
2
votes
3 answers

convert mysql timestamp to mktime

I have the following MySQL timestamp: 2009-06-23 16:21:48 How can I convert it to a format like mktime()?
rashcroft
1
vote
2 answers

Perl localtime error

I get the epoch time at February 28th 2009, then add to it the number of seconds in a week. But then I get March 4th instead of March 7th. Why? The following is the code: #!/usr/bin/perl use POSIX; my $hours_per_day = 24; my $hours_per_week …
john-jones
  • 7,490
  • 18
  • 53
  • 86
1
vote
4 answers

mktime() into mysql datetime column?

I don't know if it's possible, but I'm trying to assign different dates to each user as the are entered into the database using a loop (I know that bit's possible). To do this I'm building the timestamp using mktime() but my column is datetime (for…
AviateX14
  • 760
  • 4
  • 18
  • 36
1
vote
1 answer

Problems formatting a date

I am trying to write a function to format a date and time for me. I have an almost identical function which formats just a date. That function works fine. I just added some code to try and have it format the date with a time. It should return…
Josh Curren
  • 10,171
  • 17
  • 62
  • 73
1
vote
3 answers

How to set an specific date?

I'm trying to create an date with $date_end = mktime(0, 0, 0, date('m'), date('d')+7, date('Y'), $date_set); The output is today + 7 days instead of the date given + 7.
Muiter
  • 1,470
  • 6
  • 26
  • 39
1
vote
3 answers

How can I convert the day of the year (365 days) equivalent date December 31

how can i use the c++ library such as mktime() to convert day to dates instead of making my own algorithm
rob
  • 41
  • 2