w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Converting unix timestamp to human readable date and time in clojure
Take a look at clj-time For example here is how you would convert a (long) timestamp to DateTime: user=> (from-long 893362442345) #<DateTime 1998-04-23T20:14:02.345Z> Here is how to "split" it by date/time portions: user=> (unparse (formatters :date) (from-long 893362442345)) "1998-04-23" user=> (unparse (formatters :time) (from-long 893362442345)) "20:14:02.345Z" Depending on how you need the result to be formatted, you can choose from many different built in formatters: user=> (show-formatters) :basic-date 20130828 :basic-date-time 20130828T175957.850Z :basic-date-time-no-ms 20130828T175957Z :basic-ordinal-date 2013240 :basic-ordinal-date-time 2013240T175957.8

Categories : Unix

how do you convert epoch to readable date format in javascript
You can use the Highcharts.dateFormat function. Note you have to multiply your epoch number with 1000, as Highcharts.dateFormat needs a JavaScript date timestamp (milliseconds since Jan 1st 1970). tooltip: { enabled: true, formatter: function() { return '<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%d.%m.%Y', this.x*1000) +': '+ this.y; } },

Categories : Javascript

How to get time interval since unix epoch reference date with precision down to the second?
Assuming all devices deliver the exact same value at the exact same time. That's a big (and invalid) assumption, because it's unlikely that the system time is exactly in sync on multiple devices. Asking for the current time depends on what the device thinks the current time is, and this is not guaranteed to be correct to sub-second precision. If you wanted more precise time, you'd probably need to embed network time protocol code in your app and check with a time server. You might be better off looking into local device-to-device communication to try to sync up animations-- Bluetooth, wifi, or even something like having one device play a sound that the others can hear that would trigger the animation (e.g. a "click track", playing a repetitive sound, that other devices could sync up

Categories : Iphone

Communication protocol: human readable vs non-human readable
I'm a web developer and I have a strong preference for using human-readable protocols at the outset. For example, json. They have the advantage of being easy to debug and easy to prototype. Furthermore, they allow you to reach for all the low hanging fruit, such as rough system architecture and major bottlenecks without having to do mental translation at each step. If later on you discover that the human readable version is a major bottle neck, you can address it then. I suspect you'll very often have other things you can optimize first.

Categories : Sockets

Convert human readable number range to Regex
Validating a number is in a range of numbers with regex is tricky problem. These regexs will match a number within a given range: [0-9]{1,7} # 0-9999999 [1-9][0-9]{2,6} # 100-9999999 ([4-9][0-9]{4}|[1-9][0-9]{5,6}) # 40000-9999999 It starts to get out of hand when you have complex ranges (?:5(?:4(?:3(?:2[1-9]|[3-9][0-9])|[4-9][0-9]{2})|[5-9][0-9]{3})|[6-9][0-9]{4}|[1-9][0-9]{5}|[1-8][0-9]{6}|9(?:[0-7][0-9]{5}|8(?:[0-6][0-9]{4}|7(?:[0-5][0-9]{3}|6(?:[0-4][0-9]{2}|5(?:[0-3][0-9]|4[0-3])))))) # 54321-9876543

Categories : Javascript

Get User location and Convert into human readable address
When you retrieve your users location, that's coming from your browser apis. Thats not a google call. When it comes to geocoding, there are limits for private users (2500 geocoding requests per day) + commercial (100000 per day). But its OK to use both services together. I'd like to ask you to take a look in the FAQs https://developers.google.com/maps/faq?hl=en#usagelimits

Categories : Google Maps

Java - Convert Human Readable Size to Bytes
I've never heard about such well-known library, which implements such text-parsing utility methods. But your solution seems to be near from correct implementation. The only two things, which I'd like to correct in your code are: define method Number parse(String arg0) as static due to it utility nature define factors for each type of size definition as final static fields. I.e. it will be like this one: private final static long KB_FACTOR = 1024; private final static long MB_FACTOR = 1024 * KB_FACTOR; private final static long GB_FACTOR = 1024 * MB_FACTOR; public static double parse(String arg0) { int spaceNdx = arg0.indexOf(" "); double ret = Double.parseDouble(arg0.substring(0, spaceNdx)); switch (arg0.substring(spaceNdx + 1)) { case "GB": return re

Categories : Java

UNIX TIMESTAMP GMT stored in sqlite in Integer, convert to local time zone
SELECT id,date,name FROM task WHERE datetime('date', 'unixepoch', 'localtime') = datetime('now','unixepoch'); This will work. But the left hand side value will never match with the right hand side and you will never retrieve a value, because you are capturing timestamps, by the time you compare, the timestamp value would have changed. so , SELECT id,date,name FROM task WHERE converttolocal(date) = now; will never be true .

Categories : Objective C

How do I do auto conversion of Rails time to Unix epoch time?
Why don't you just make a method you can patch in to ActiveRecord::Base? def created_epoch self.created_at.to_f end Then you won't have to remember to convert, you can just use that method instead.

Categories : Ruby On Rails

android convert unix time to utc date
I'm not sure exactely how are you formatting your date object, but by setting the timezone to the dateformat object (to GMT) I'm able to get Mon May 06 09:29:28 GMT 2013 AM which is the same date you are looking for. long time = 1367832568 * (long) 1000; Date date = new Date(time); SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy a"); format.setTimeZone(TimeZone.getTimeZone("GMT")); Log.d("date", format.format(date));

Categories : Java

Conversion from DateTime to Unix Epoch Time in Current Timezone
This is almost certainly the most immediate problem: c.Set(CalendarField.Month, month); My guess is that you're expecting 1 to mean January here - but java.util.Calendar uses 0-based months. You probably want: c.Set(CalendarField.Month, month - 1); There may also be time zone issues, but concentrate on the big ones first - being out by a whole month will almost never be a time zone issue. Alternatively, to get the milliseconds since the unix epoch, you can stick to the .NET types - or even use my Noda Time library. Using just DateTime: private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); static long GetMillisecondsSinceUnixEpoch(int year, int month, int day, int hour, int minute) { DateT

Categories : C#

How to convert an ELF executable to C code? The generated C code need not be human-readable
This will give you (almost) an assembly code translation: objdump --disassemble <elf file> I say almost because the output contains some annotations like binary file position markers and can't serve directly as input to an assembler, but it's close.

Categories : C

How to convert from hex-encoded string to a "human readable" string?
Change "hex" to "hex_codec" for Pyton < 3 This applies to python 3+ Possible to use? >>> codecs.decode(b"4f6c6567", "hex_codec") b'Oleg' >>> codecs.getdecoder("hex_codec")(b"4f6c6567") (b'Oleg', 8)

Categories : Python

How to convert time to epoch
strtotime($starts); http://php.net/manual/en/function.strtotime.php Refer the php documentation for more details. Note : UNIX Epoch is always in UTC. So always set the default timezone using the date_default_timezone_set(); function to get the desired output.

Categories : PHP

What is this time format, and how do I convert it to an epoch?
Well, these just look like hexadecimal numbers, which would be seconds since 1/1/1970 UTC. 3F536DDA hex == 1062432218 dec == Mon, 01 Sep 2003 16:03:38 GMT 3F52C3C3 hex == 1062388675 dec == Mon, 01 Sep 2003 03:57:55 GMT The other numbers look like decimal microseconds since 1/1/1970 UTC, but they aren't equal to those other numbers: 1378397085768000 == Thu, 05 Sep 2013 16:04:45 GMT 1378353476238000 == Thu, 05 Sep 2013 03:57:56 GMT If those aren't the dates you had in mind, then there is some other epoch involved. For example, if they originated in Microsoft Windows, they will certainly be different. Where did you get them from? That knowledge will help in their interpretation. UPDATE Since you said they are based on Jan 6 1980 epoch, then you can do something like this: var d =

Categories : Javascript

In R how to convert a formatted local time to epoch?
You can use as.integer to get seconds since epoch began... x <- as.POSIXct( Sys.time() ) #[1] "2013-08-27 12:37:17 BST" class(x) #[1] "POSIXct" "POSIXt" as.integer( x ) #[1] 1377603437 Using a vector of strings called times: times #[1] "2013-08-27 12:39:32" "2013-08-27 12:39:33" "2013-08-27 12:39:34" #[4] "2013-08-27 12:39:35" "2013-08-27 12:39:36" "2013-08-27 12:39:37" #[7] "2013-08-27 12:39:38" "2013-08-27 12:39:39" "2013-08-27 12:39:40" #[10] "2013-08-27 12:39:41" as.integer( as.POSIXct( times ) ) #[1] 1377603609 1377603610 1377603611 1377603612 1377603613 1377603614 #[7] 1377603615 1377603616 1377603617 1377603618 Without the timezone in the strings you will probably have to specify the tz argument to as.POSIXct, e.g. as.integer( as.POSIXct( times ) , tz = "BST" ) for Brit

Categories : R

Twitter created_at convert epoch time in python
Read the documentation of time.mktime It requires struct_time, or you can alternatively represent it using a 9-tuple. The required entries are: Year Month Date Hour Minute Second Day in week Day in year Daylight Savings Time This is not the function you need, however. It seems that you want to use strptime instead. According to the documentation: Parse a string representing a time according to a format. The return value is a struct_time as returned by gmtime() or localtime(). >>> import time >>> time.strptime("30 Nov 00", "%d %b %y") time.struct_time(tm_year=2000, tm_mon=11, tm_mday=30, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=335, tm_isdst=-1) So, you can do: time.strptime(created_at)

Categories : Python

Convert mysql varchar to float or epoch time?
unix_timestamp() takes a date as input. It doesn't make sense to call it on a varchar like 1370449004.766663. To convert a varchar column to a float column, you could: alter table YourTable add FloatColumn float; update YourTable set FloatColumn= convert(time, float); It's an even better idea to store a date as a datetime column: alter table YourTable add DateTimeColumn datetime; update YourTable set DateTimeColumn = from_unixtime(convert(time, float));

Categories : Python

Converting epoch time into mm-dd-yyyy local date
Well, depending on what you mean by "manually", you can do it in a couple of short steps: # demo. # Put the whole local time/stat/etc in parentheses where I put localtime. # ($m,$d,$y) = (localtime)[4,3,5]; # extract date fields using a list slice $modtime = sprintf('%02d-%02d-%4d', $m+1, $d, $y+1900); # format the string There's probably a way to do it in a single line, incorporating both the extraction and a more complex format string, but that would lead to unnecessary obfuscation. -Tom Williams

Categories : Perl

How to convert ( round ) epoch Time to nearest hour and day wrt IST (in Java)
Certainly, you won't get a method to accomplish this. Why not use java.util.Calendar's methods get(int field) and set(int field, int value). I'm positive that it can be done with these methods and a bit of rounding logic.

Categories : Java

Comparing an epoch with current date in epoch format
Try something like: select f_id from data_history where (extract(epoch from f_lastmodified) + f_retention_period) < extract(epoch from now()) When you wrote: from (select (extract(epoch from now()))) as epochNow you created a subquery thar returns 1 row with one column. And you named this subquery epochNow

Categories : Postgresql

get human readable AST from c++ code
Probably the best way is to write a program on your own with libclang. Check the API Documentation of libclang, specially the C++ AST introspection part.

Categories : C++

Convert Mongo Datestamp to R readable date format.
You need to include %Y for the four-digit year. fmt <- "%a %b %d %H:%M:%S EAT %Y" as.Date("Thu May 08 01:00:00 EAT 2008", fmt) ## [1] "2008-05-08" strptime("Thu May 08 01:00:00 EAT 2008", fmt) ## [1] "2008-05-08 01:00:00" When you come to print the values, use strftime or format, and specify how you would like the dates to look.

Categories : R

Human readable dynamic segments
You can override the serialize function on your Route. http://emberjs.com/api/classes/Ember.Route.html#method_serialize

Categories : Ember Js

Access human readable UIElement label from IOS app
There are lots of ways to do what you want to be done. Here are several of them: @properties The first thing that came to my mind are properties. Use your view controller as a storage class by adding following property declarations in your header file: @property (nonatomic, weak) IBOutlet UIView *myFantasticView; @property (nonatomic, weak) IBOutlet UIView *myGorgeousView; ... Then, just simply connect your views to specific outlets in Interface Builder. The only drawback is that you will have to declare a lot of properties which can become a little confusing. Custom runtime attributes (another use of @properties) If you're using UIView's subclasses (I assume you do), you can use your UIView subclass and declare an "identifier" property: @interface MyView : UIView @property (nona

Categories : IOS

How to serialize an XmlDocument to a well-formatted human-readable XML?
If you're using XmlTextWriter to write to the file, you can set its Formatting property to Formatting.Indented before you write.

Categories : C#

Nonintrusive serializer to human readable format
The JSON format is pretty human readable: JavascriptSerializer is built into the framework and would allow you to serialize any instance to JSON format. Limitations apply of course: if your object graph contains circular references you will not be able to JSON serialize it.

Categories : C#

Human readable fractional numbers in Rails?
Actually, I think I have something for you. Set up the rails fractions plugin in your project. Then, write your own helper, like so: (pseudocode) def pluralize_and_humanize(number, string) split number into integer and fractional part -> whole, fraction convert fraction to [nice_fraction][2] if there is a fractional component output whole number + nice_fraction + pluralized string end Now, I'm not helping you with outputting "and a half" or "and a quarter" but I think '2 1/2' would at least be better than 2.5.

Categories : Ruby On Rails

File Mime Type to Human Readable Name
Simplest way is to copy-paste a list of mime types and descriptions (like from here http://www.freeformatter.com/mime-types-list.html#mime-types-list) and then just create an array of it..

Categories : Ruby On Rails

How do you put the datetime in the guage chart in human readable format
Don't convert that value. Instead use dataLabel formatter: http://jsfiddle.net/AVLeH/ plotOptions: { gauge: { dataLabels: { formatter: function () { return Highcharts.dateFormat('%d/%m/%Y %H:%M', this.y); } }, } },

Categories : Javascript

How do I format CouchDB design documents in a human readable way?
In addition to mentioned Futon, there are several tools that allow you to write your map and view functions with your favorite editors and save them on your local file system. Those tools than take care of "pushing" your code to CouchDB. You can find more about those tools here

Categories : Javascript

JPA Criteria API: how to dump a human-readable representation for Predicates
This works fine for me with EclipseLink 2.3/2.4: import org.eclipse.persistence.internal.jpa.querydef.SelectionImpl; public static String getPredicateAsString(final Predicate predicate) { if (predicate == null) { return null; } if (!(predicate instanceof SelectionImpl<?>)) { // type guard return "not supported"; } return ((SelectionImpl<?>) predicate).getCurrentNode().toString(); } Sample output from getPredicateAsString: Logical operator [ AND ] Relation operator [ <> ] Query Key age Base model.Person Constant 42 Function operator [(, IS NOT NULL)] Query Key currentJob Base model.Employer

Categories : Java

In PHP, is there a way to display human-readable information about a variable in error_log()?
print_r() accepts a second parameter which will return its output as a string. As such, your first example can be modified to the following: error_log('this is information about the variable: ' . print_r($variable, true)); Note: While var_dump() does not have such a parameter, you could use output buffering to store its output as described in the docs.

Categories : PHP

How to make both readable and calculable Date/Time in shell script?
If you have GNU date, you can use the epoch time date -d @$START +%c Otherwise, do read start start_display < <(date +"%s %c") # ... read end end_display < <(date +"%s %c") diff=$(( $end - $start )) echo "Start time: $start_display" If you're not using a shell capable of process substitution, set -- $(date +"%s %c") start=$1; shift start_display=$* If you use bash, take advantage of the builtin $SECONDS variable, which starts at zero for a new bash process and increments each second. start_display=$(date) # ... echo "Start Time: $start_display" echo "End Time: $(date)" echo "Running time: $SECONDS seconds"

Categories : Shell

Getting human-readable stack trace when testing REST API modules
Resolved. Actually, it was logical : If you change the "Accept:" request header (example -H "Accept: application/json" in Curl) the trace will be returned as Json by the server if an error occurs.

Categories : Rest

show forms data in human readable format django
I think you want that: class PersonActionsForm(forms.ModelForm): class Meta: model = Actions fields = ('action',) widgets = { 'action': forms.CheckboxSelectMultiple(), } See here

Categories : Django

Hunspell/Aspell data conversion to human-readable inflection list
There is a method that the command line one does, but it doesn't output quite in the format you're looking for. You could also do this manually if you wanted though just by some simple scripting with regex. The format of for each set of affixes is TYPE TAG REMOVE REPLACE MATCH Such that where TAG matches what follows what's behind the /in a given word in the .dicfile, you can do the following (presuming you've already stripped the word of the /...): if($word =~ /$match$/) $word =~ s/$remove$/$replace/; Notice the $ there matching the end-of-line/word. Adjust with ^ if it's a prefix. There are three caveats: The $match directly from the .aff file is in almost all cases equivalent to standard regex. There are minor variations such that if the match is something like [abc-gh], yo

Categories : Misc

Mapping Android device models to human-readable brand names
Unfortunately, android.os.Build.MODEL returns the model name, such as GT-I9300 MODEL in many cases will return what you consider the "brand name" to be. It will vary by device, manufacturer, and carrier. Where can I find a complete list of devices with a mapping There is none. You won't even find a complete list of every Android device model ever manufacturered, let alone some three-dimensional matrix mapping models to carriers to "brand names" in all relevant human languages. Moreover, since you cannot necessarily determine the carrier responsible for the device's manufacture (which may differ from the carrier whose SIM is in the device), you may lack sufficient detail at runtime to make this mapping in all cases. or a better solution for this mapping issue? Get rid of t

Categories : Android

How can I store C structures in human-readable files using the fewest lines of code?
"Shortest" have several meanings fast to process eating as little as memory as possible easy and quick to code I would suggest to use a simple textual format to serialize them, probably JSON (or maybe YAML or XML). The advantage of such formats is that they remain somehow human "readable" (at last for a programmer). There exist a lot of JSON libraries (notably in C and C++): jansson in C, jsoncpp for C++, etc etc... Does your scientific instrument runs only a tiny 8 bit controller? If yes, you might be constrained by code size... And I suggest also to document the serialized format.

Categories : C

How to convert the extract time in "hr:min:sec" from UNIX time stamp in PHP?
The date function is what you need: $timestamp = time();//or whatever your timestamp source is date('h:i:s A', $timestamp);

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.