I'm using highcharts. I'm trying to change its date to Persian but since it is using Date.UTC I can not change it!
I've seen the http://api.highcharts.com/highstock#lang but it seems that it doesn't support persian.
Do you know any way to change it into persian date?
One method I can come across with is the algorithm that changes UTC date to Persian date.
Is there any way to solve this problem?
Please help me...
Thank you
You will have to do a bit of work to get this into highcharts.
Firstly, find a javascript library which converts dates to persian date. This one looks promising: http://intldate.codeplex.com/
Secondly, you need to customise the highcharts date formatting. Highcharts provides an API to do this:
http://api.highcharts.com/highcharts#Highcharts.dateFormat()
You need to use the dateFormats hook to add a %P option to the date format string which prints in persian format using the javascript library you choose. Once you have defined a %P format, you can customise the date formats to be used on the x-axis: http://api.highcharts.com/highcharts#xAxis.dateTimeLabelFormats
{
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%P',
week: '%P',
month: '%P',
year: '%P'
}
Note, you can define several dateFormat parameters, not just %P, to handle days, months etc.
Related
I have a piece of text I need to transform into a date:
"12/28/20 10:44 PM"
Any of the usual tricks are not working to get sheets to recognize this as a date.
I've made progress parsing out the date and time into separate cells but it still won't factor in the AM PM part.
Is there a quick way to convert to a date for this type of format?
try:
=REGEXREPLACE(A1; "(\d+)\/(\d+)\/(\d+)"; "$2/$1/20$3")*1
then:
I am saving dates with the followings formats 1985-01-04 and 19850104, then I need to show the format Year of this way 1985 January 4.
but, i got this got: 04 January 1985.
could I change this format? I'm using rails 6.
I have wanted to change this option default because I am implement testing with this format: 1985 January 4.
Use 'strftime' to format a date for your needs:
Time.now.strftime("%Y %B %d")
See this cheat sheet for many other options of date formatting with strftime:
https://www.shortcutfoo.com/app/dojos/ruby-date-format-strftime/cheatsheet
Looking for the best way to convert a string like "01/16/2016" into a friendly date format that rails can handle.
I have a calendar in which users can select a from_date and a to_date.. based on those params, my search will then filter results that fit the time periods.
Unfortunately, rails cannot handle the current format its in. Not sure the best way to go about this. I could change the search form's javascript to display the date differently, but I feel this format is most user friendly.
thx!
You can use the standard ruby Date class:
some_date = Date.strptime('01/16/2016', '%m/%d/%Y')
some_date will be an instance of Date, which then you can handle in rails and reformat in any way you want using strftime.
As like taglia said you can use the strptime
Date.strptime('01/16/2016', '%m/%d/%Y')
You can change the calendar date format from dd/mm/yyyy to mm/dd/yyyy, then you can use
require 'date'
date = DateTime.parse("16/01/2016")
=> #<DateTime: 2016-01-16T00:00:00+00:00 ((2457404j,0s,0n),+0s,2299161j)>
date.strftime('%a %b %d %H:%M:%S %Z %Y')
=> "Sat Jan 16 00:00:00 +00:00 2016"
You can use Date instead of DateTime if you want only the date.
I am trying to convert a Hijri date back to Gregorian with the internal function in the ar-SA calendar (other calendars seem to have the same toGregorian function). For example code try:
Globalize.cultures["ar-SA"].calendars.standard.convert.toGregorian("1434", "03", "11");
According to sites I've seen like: http://www.islamicity.com/prayertimes/defaulthijriconv.asp
"1434", "03", "11" should be 1/23/2013.
However, each date seems to be off by 2 days and this function returns.. 1/21/2013..
Is there a problem with this function? Or some other issue I could be having by using it?
Or can someone propose a js function which would do the correct conversion?
I figured out the problem it is because Month is zero based so the above code should be:
Globalize.cultures["ar-SA"].calendars.standard.convert.toGregorian("1434", "02", "11");
For todays date.
I have a birthday field in my database which has a date value as yyyy-mm-dd. I want to display it as being more human friendly. So 2011-11-15 should show up as Tuesday, November 15th, 2011.
The very strange thing is that when i do a #user.birthday in rails console, the value does show up in the format I want. But not on the web.
I am not sure what's going on.
The reason it does not show up in the right format is that Rails in the view does call a to_s if necessary.
You should the Internationalization and Localization of Rails to do that.
So in your example, I18n.l #user.birthday should do the trick. You should check what the default date format for your locale is, this is located at `config/locales/.yml. You may add your format by following the explanation in "How to store custom translations". So by adding
en:
date:
formats:
default: "%A, %B %d,%Y"
this format will be used where ever you call I18n.l on a date.
#user.birthday.strftime "%A, %B %d,%Y"
Try this <model>.created_at.to_date.to_s(:long)