I read in two strings with a Year, the Julian Day (year day), hour, minute, and an observation.
I pull the relevant variables out using sscanf:
sscanf(tide_str1.c_str(), "%d %d %d %d %Lf", &y1, &j1, &h1, &m1, &obs1);
sscanf(tide_str2.c_str(), "%d %d…
I need help getting the previous months full date range in the following format: Y-m-d
I have successfully been able to get "this" months full date range but not the "previous" months full date range.
Any help is greatly appreciated!
I want to convert a huge file containing datetime strings to seconds since UNIX epoch (January 1, 1970) in C++. I need the computation to be very fast because I need to handle large amount of datetimes.
So far I've tried two options. The first was…
I'm working on some time related features and I opt to always use UTC times and store time stamps as integers for consistency.
However, I noticed that when I use mktime it seems that the currently set time zone has an influence of the return value…
I have been playing with mktime, and I noticed a weird, and inconsistent, behavior.
I provide it with a date which is not during DST (daylight saving time), but with tm_isdst is set to 1, what mktime usually does is change tm_isdst to 0, and adjust…
I am having a strange problem with PHP and a C script that uses the current time. My program is a little complex, but the problem narrows itself to this:
I have this C code which prints the date 1 minute ago, the current date, and the date 1 minute…
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…
I would like to see if at 00:00:00 on January 1, 1970 it actually corresponds to 0 seconds, and I wrote the following:
#include
#include
int main(void) {
int year = 1970;
struct tm t = {0};
t.tm_mday = 1; //…
I am using this code to generate yesterday's beginning of day in PST (aka America/Los_Angeles) time. I can't figure out how to convert the result to UTC.
date_default_timezone_set("America/Los_Angeles");
$time1 = date("Y-m-d H:i:s", mktime(0,0,0,…
I'm collecting a users input as "DD/MM/YYYY"
The aim is to pass into mktime as csv YYYY,MM,DD.
puts "Please enter dob in dd/mm/yyyy format;"
inp = gets.chomp
inp = inp.gsub(" ","")
while inp.length != 10
puts "Please use dd/mm/yyyy format"
inp…
What I would like to do with my simple program is to calculate a difference in seconds between two dates.
time_t referenceDate;
time_t dateNow = time(0);
struct tm referenceDateComponent = {0};
referenceDateComponent.tm_hour =…
I am trying to implement in C two simple convertors, date/time to time-stamp and vice-versa, without any dependencies on time library routines (such as localtime, mktime, etc, mainly due to the fact that some of them are thread-unsafe).
I have…
Am am current facing a problem that need a solution ASAP.
I am trying to list all months of the current year(2012) by using the following code:
for ($m=1; $m<=12; $m++) {
$month = date('F', mktime(0,0,0,$m));
echo $month. ' ';
…
Can someone help me understand why I get "-1" returned by mktime in the following code. Thanks.
#!/usr/local/bin/bash
f_name="crap.stat"
S_Date="2012-02-10"
E_Date="2012-02-13"
gawk -F '\t' -v s_date="$S_Date" -v e_date="$E_Date" 'BEGIN {s_time =…
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…