I use php and dynatable.js (version 0.3.1) to create dynamic tables with a sort and search function. This setup works very well even with the U.S. formatted date from the SQL database. But I need the german date format in the table (dd.mm.yy or dd.mm.yyyy) to sort the entries.
I can't find a solution for my problem in the documentation from dynatable.js. Has someone had a similar problem with the date format in dynatable and maybe a hack or other kind of solution?
Related
Hi I'm kinda stuck with this small problem. I am working on a project in Neo4j 3.2.2 which requires me to extract the day(like Monday,Tuesday etc) out of the entered date in dd/MM/yyyy string format.
I've searched a lot on web for its solution but couldnt find one. I even checked previous stack overflow posts but couldnt find anything related to this so finally thought of posting it here. Any help would be highly appreciated.Thanks.
There are many APOC Date and Time functions.
For example, this Cypher query:
RETURN apoc.date.fields('07/13/2017', 'MM/dd/yyyy');
returns this:
{"weekdays":4,"years":2017,"zoneid":"UTC","months":7,"days":13}
A "weekday" value of 4 represents "Thursday" (and a 7 would represent "Sunday"). The other fields should be self-explanatory.
I know there was a lot of discussion about datetime parsing in dygraphs and problems with Javascript. But still, I have a problem how to correctly pass datetime.
I'm using dygraph to show data (points with 5 seconds interval) and it's crucial to have correct datetime. But if I pass datetime as timestamp (1401580800) or as ISO 8601 (2014-06-01T00:00:00+00:00), I always get datetime modified to my local time.
My question is, how to correctly pass the datetime to dygraph so datetime doesn't change?
Dygraphs use Javascript Dates, which display according to your local timezone (unfortunately, there's no way to display them using an arbitrary timezone).
One solution is to modify the data - I've encountered a similar problem in my own work, and I made a small helper function to make fake Javascript UTC dates (basically ending up with a Javascript date that's actually the wrong time but shows up looking correct when displayed in local time). This worked for my application, which used moments (http://momentjs.com/) to represent dates everywhere unless required by some other library to use Javascript's Dates.
Another (probably more correct) solution is to modify Dygraph's functions to display the right things, as demonstrated in the answer to this post: Dygraph showing dates in an arbitrary Timezone
The JavaScript Date object will always use the local time of the computer it's running on. If you don't want that behavior, you'll need to use something else. Consider building a pre-formatted string using something like moment.js and then just pass the string to dygraphs instead of the date.
I am developing a Rails application using ActiveScaffold.
The thing is that I need to filter a list of results by a date range.
(SQL equivalent 'BETWEEN ? AND ?')
I know that ActiveScaffold has a feature that already does that, but it has too many options.
(Past, Future, Range, =, ...., Between). In this case, I only need the Between option in that combo.
I tried overriding the field using the Helper, but the closest I got was to display 3 different combos (one for year, one for month, one for day).
Is there any way to override Active Scaffold so that only displays the "Between" option?
EDIT
Active Scaffold already does the search part well.
I am trying to change the visual part so it doesn't display so many options.
EDIT 2
The calendar plugins for rails are dated from 2009 or they aren't under maintenance.
You can use a range as a parameter in AR.
Model.where(:date => from..to)
Also, I'm not sure if ActiveScaffold has something to do with it. Normally, all the tasks like this one can be perfectly solved within plain ActiveRecord.
EDIT:
As it turns out, author also needs to get the user's input for the boundaries.
This is a common task that can be solved with one of the thouhands js plugins for datepickers.
I would recommend you not to stick to ActiveScaffold for that purpose.
Try this simple Jquery datepicker, and it will turn normal text field into that drop-down calendar. You will only need several lines of javascript then.
If you need further advise, just ask.
Apologies if the title is not clear, I' not really sure how to explain this clearly.
In a Rails app I'm pulling in users' data from a 3rd party provider's API. One of the attributes is the user's birthday.
I am storing the hashed data in my database and, in certain circumstances, need to display the user's birthday in the view.
The problem is that the birthday is not formatted as a Date. Within the hash, it is in the format mm/dd/yyyy. This means that my usual date scoped formats don't work on it.
Given that I am extracting the birthday from the hashed data column as follows
<%= #user.hashed_data["info"]["birthday"] %>
what is the best/ most efficient way to handle this so that I can display localized date formats?
Do I need to split on the / symbols, and then recombine the resulting string to a date? Or am I overcomplicating this?
Thanks for any suggestions.
Try:
Date.strptime('01/31/2011', '%m/%d/%Y')
# => #<Date: 2011-01-31 (4911185/2,0,2299161)>
The simplest way to convert plain text to date or datetime is to use the chronic gem.
A very usefull parameter that you can pass to the chronic parser is the :endian_precedence . See my answer here for more details.
Regards, Dorian
I'm scoping out how to handle user-generated dates with rails and was hoping to get some thoughts on the best way to handle them. Ultimately I want to display dates/times provided by the user in HTML, and I also want to sort by the dates (ascending and descending, depending). My initial thought was to create the db as time: string and date:string and then convert these strings to datetime values. Is there a better way to go about this? I'm using RoR 3.1.
Any thoughts and ideas would be greatly appreciated so I don't start down the wrong path only to realize at a later date.
Yes, there is a better way to go about it. ActiveRecord supports the following types for times:
datetime
timestamp
time
date
So pick the type that matches your intent (time for time of day, date for a date, ...) and then let AR do its job and deal with the details. Then you'll get the right data in the database and the right objects in your Ruby; once you have the right objects in your Ruby everything will sort and compare and what not properly.