epoch

Converting UTC string to epoch time in javascript

时光毁灭记忆、已成空白 提交于 2019-11-28 10:14:41
How can I convert UTC date-time string (e.g. 2011-03-29 17:06:21 UTC ) into Epoch (milliseconds) in javascript? If this is not possible, is there any way to compare (like <, >) UTC date time strings? Note that UTC date strings can be compared lexicographically, like strings, since the higher order values appear leftmost in the string. var s1 = '2011-03-29 17:06:21 UTC' , s2 = '2001-09-09 01:46:40 UTC'; s1 > s2; // => true s2 > s1; // => false You can extract the date fields from your example string and return the number of milliseconds by using the Date.UTC method: var getEpochMillis =

How do I get epoch time in C#? [duplicate]

£可爱£侵袭症+ 提交于 2019-11-28 07:06:53
Possible Duplicate: How do you convert epoch time in C#? I'm trying to figure out how to get the epoch time in C#. Similar to the timestamps given on this website: http://www.epochconverter.com/ Does DateTime have a method for that? TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); int secondsSinceEpoch = (int)t.TotalSeconds; Console.WriteLine(secondsSinceEpoch); 来源: https://stackoverflow.com/questions/9453101/how-do-i-get-epoch-time-in-c

Convert mysql DATETIME column to epoch seconds

不问归期 提交于 2019-11-28 07:00:30
问题 I have a column mysql datetime that is in DATETIME format. Is there a way to SELECT this column in epoch seconds? If not, what would be the best way of converting the datetime format to epoch seconds? What type of field would be the best to capture this? 回答1: Use MySQL's UNIX_TIMESTAMP function 回答2: You can use : SELECT UNIX_TIMESTAMP(yourfield) FROM yourtable; And for UPDATE, the invers function is : FROM_UNIXTIME(...) 来源: https://stackoverflow.com/questions/10839151/convert-mysql-datetime

jquery convert number to date? [duplicate]

筅森魡賤 提交于 2019-11-28 06:49:34
This question already has an answer here: Convert UTC Epoch to local date 15 answers i have a json file that returns "date_created":"1273185387" in epoch format i want to convert it to something like this Thu, 06 May 2010 22:36:27 GMT any script to do this conversion? var myObj = $.parseJSON('{"date_created":"1273185387"}'), myDate = new Date(1000*myObj.date_created); console.log(myDate.toString()); console.log(myDate.toLocaleString()); console.log(myDate.toUTCString()); http://jsfiddle.net/mattball/8gvkk/ Try the below code... var myDate = new Date( your epoch date *1000); alert(myDate

How do I get the unix timestamp in C as an int?

只谈情不闲聊 提交于 2019-11-28 04:29:16
I would like to get the current timestamp and print it out using fprintf . For 32-bit systems: fprintf(stdout, "%u\n", (unsigned)time(NULL)); For 64-bit systems: fprintf(stdout, "%lu\n", (unsigned long)time(NULL)); Is just casting the value returned by time() #include <stdio.h> #include <time.h> int main(void) { printf("Timestamp: %d\n",(int)time(NULL)); return 0; } what you want? $ gcc -Wall -Wextra -pedantic -std=c99 tstamp.c && ./a.out Timestamp: 1343846167 To get microseconds since the epoch, from C11 on, the portable way is to use int timespec_get(struct timespec *ts, int base)

Convert Epoch Time string to Time

风格不统一 提交于 2019-11-28 02:14:30
问题 I've been looking for a way to convert a string (in Epoch time) into a date. Basically, I need to take this: 1360440555 (in string form) and make it into this: Feb 9 12:09 2013 . I've been looking at strptime and strftime, but neither seems to be working for me. Any suggestions? Edit: Thanks, guys. I converted it to an int with atoi() , cast it as time_t , then ran ctime() on it. Worked perfectly! 回答1: If only you had that value in an integer instead of a string, you could just call ctime .

Timestamp to Epoch in a CSV file with GAWK

戏子无情 提交于 2019-11-28 00:48:45
问题 Looking to convert human readable timestamps to epoch/Unix time within a CSV file using GAWK in preparation for loading into a MySQL DB. Data Example: {null};2013-11-26;Text & Device;Location;/file/path/to/;Tuesday, November 26 12:17 PM;1;1385845647 Looking to take column 6, Tuesday, November 26 12:17 PM, and convert to epoch time for storage. All times shown will be in EST format. I realize AWK is the tool for this, but can't quite seem to structure the command. Currently have: cat FILE_IN

Converting time_t to int

时光总嘲笑我的痴心妄想 提交于 2019-11-28 00:26:37
I want to convert a given time into epoch(time_t) and vice versa. can anyone tell what is the routine or algorithm for this? Thanks Update epoch_strt.tm_sec = 0; epoch_strt.tm_min = 0; epoch_strt.tm_hour = 0; epoch_strt.tm_mday = 1; epoch_strt.tm_mon = 1; epoch_strt.tm_year = 70; epoch_strt.tm_isdst = -1; double nsecs = difftime(curtime, basetime);//current time from system, I converrting it to struct tm but this always return 32399 for some reason. You should cast it to a long int instead of int . long int t = static_cast<long int> time(NULL); An int might not be enough to hold the time, for

Why is microsecond timestamp is repetitive using (a private) gettimeoftheday() i.e. epoch

自闭症网瘾萝莉.ら 提交于 2019-11-27 23:02:01
问题 I am printing microseconds continuously using gettimeofday(). As given in program output you can see that the time is not updated microsecond interval rather its repetitive for certain samples then increments not in microseconds but in milliseconds. while(1) { gettimeofday(&capture_time, NULL); printf(".%ld\n", capture_time.tv_usec); } Program output: .414719 .414719 .414719 .414719 .430344 .430344 .430344 .430344 e.t.c I want the output to increment sequentially like, .414719 .414720 .414721

Can strict JSON $dates be used in a MongoDB query?

微笑、不失礼 提交于 2019-11-27 15:56:47
问题 I'm trying to write a date comparison query using MongoDB's strict JSON representation of BSON . I'd like it to work in the MongoDB shell (v2.4.3) Here's what I've tried... Setup: create a new document with an at date of Jan 1, 2020 > db.myTimes.insert({"at": new Date("2020-01-01")}) Using non-strict query for date > 2010, no problem: > db.myTimes.find({"at": {"$gt": new Date("2010-01-01")}}) { "_id" : ObjectId([snipped]), "at" : ISODate("2020-01-01T00:00:00Z") } Using strict JSON query,