I am trying to implement a date on Google Sheets in a way that it is translated to a different language programatically:
If I have =TEXT("01/01/2020","DD MMMM YYYY") I get 01 January 2020.
If I change my Google sheets language settings to spanish, I will get 01 Enero 2020.
However, I am looking for some =TRANSLATE('ES', TEXT("01/01/2020","DD MMMM YYYY")) so even though my settings are set to English, I still get Enero instead of January.
Is there a way to do that?
try:
=GOOGLETRANSLATE(TEXT(TODAY(), "dd mmmm yyyy"), "en", "es")
then:
=PROPER(SUBSTITUTE(GOOGLETRANSLATE(TEXT(TODAY(), "dd mmmm yyyy"), "en", "es"), "de ", ))
You could try this but I don't know how accurate it is:
=GOOGLETRANSLATE(TEXT("01/01/2020","DD MMMM YYYY"), "en", "es")
Related
I am trying to parse the date string in lang 'HR' (Croatian locale) 20. svibnja 2021 into moment date. Result should be 20-may-2021 but it is formatting to 20-Jan-2021.
moment('20. svibnja 2021', 'DD MMMM YYYY', 'HR') or
moment('20. svibnja 2021', 'LLL', 'HR')
Not sure why this is happening
How can I format a date that includes a friendly day and month literal such as:
"Thursday, June 14, 2018"
Day can be:
Sunday, Monday, Tuesday, Wedenesday, Thursday, Friday, Saturday,
Friday
Month can be:
January, February, March, April, May, June, July, August, September,
October, November, December
let formatter = DateFormatter()
formatter.dateFormat = format
return formatter.date(from: "Thursday, June 14, 2018")
What should the format be set to?
Something like this?
static let format = "DAY, MONTH, dd, YYYY"
Is it even possible to do this with DateFormatter() ?
Use EEEE for the full weekday name and MMMM for the full month name. But since you are parsing fixed formatted strings that are in English, you must also set the formatter's locale to en_US_POSIX.
let formatter = DateFormatter()
formatter.dateFormat = "EEEE, MMMM d, yyyy"
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter.date(from: "Thursday, June 14, 2018")
Note that this will treat the date as being in the user's local timezone.
See the full specification for all possible date formatting patterns.
I am trying to format a timezone based
How can i convert a JS time into these formats?
"Thu Sep 24 2015 14:00:00 GMT-0700 (PDT)"
"September 24th 2015, 2:00:00 pm UTC-07:00"
"2015-09-24 14:00:00 GMT-0700"
"Sept 24 2015 14:00:00 GMT-0700"
"Thu Sep 24 2015 14:00:00 GMT-0700 (Pacific Daylight Time)"
Converting into any of it would help.
You can use tokens listed in the format documentation, as shown in the following snippet.
Use square brackets [] to add characters that should be escaped (GMT and UTC in the example, if you need current zone abbreviation use the z token).
Note that as the moment-timezone docs says:
Moment.js also provides a hook for the long form time zone name. Because these strings are generally localized, Moment Timezone does not provide any long names for zones.
To provide long form names, you can override moment.fn.zoneName and use the zz token.
You can find in the snippet an example of providing long names for zones.
var time = "2016-11-09 15:38:00", zone = "America/Chicago";
var m = moment.tz(time,zone);
console.log(m.format('ddd MMM D YYYY HH:mm:ss [GMT]ZZ (z)'));
console.log(m.format('MMMM Do YYYY, h:mm:ss a [UTC]ZZ'));
console.log(m.format('YYYY-MM-DD HH:mm:ss [GMT]ZZ'));
console.log(m.format('MMM D YYYY HH:mm:ss [GMT]ZZ'));
// Add long names for sample zones
var abbrs = {
EST : 'Eastern Standard Time',
EDT : 'Eastern Daylight Time',
CST : 'Central Standard Time',
CDT : 'Central Daylight Time',
MST : 'Mountain Standard Time',
MDT : 'Mountain Daylight Time',
PST : 'Pacific Standard Time',
PDT : 'Pacific Daylight Time',
};
moment.fn.zoneName = function () {
var abbr = this.zoneAbbr();
return abbrs[abbr] || abbr;
};
console.log(m.format('ddd MMM D YYYY HH:mm:ss [GMT]ZZ (zz)'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.7/moment-timezone-with-data-2010-2020.min.js"></script>
I was able to make third one using this snippet
var time = "2016-11-09 15:38:00",
zone = "America/Chicago",
format = "YYYY-MM-DD HH:mm:ss zZZ";
moment.tz(time,zone).utc().format(format)
I am trying to change a simple date format "1/24/2016" to " Tuesday, Jan 24 2016"
sheet.getRange("A2:A10").setNumberFormat("EEE, d MMM yyyy");
prints:
"EEE, Jan 24 2016"
This is an undocumented feature
you can use:
range.setNumberFormat("DDD, MMM dd, YYYY");
For more details you can see the issue report here:
https://code.google.com/p/google-apps-script-issues/issues/detail?can=2&start=0&num=100&q=setNumberFormat&colspec=Stars%20Opened%20ID%20Type%20Status%20Summary%20Component%20Owner&groupby=&sort=&id=4175
I'm trying to convert string to Date, but it result incorrect date.
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd MMM YYYY"
let dt = dateFormatter.dateFromString("17 Sep 2015")
println("Date : \(dt)")
It result
Date : Optional(2014-12-20 18:30:00 +0000)
Please let me know where I'm making mistake. I tried other format too, but it return nil.
The format for year is incorrect, it should be yyyy, not YYYY.
"Y": Year (in "Week of Year" based calendars). This year designation is used in ISO year-week calendar as defined by ISO 8601, but can be used in non-Gregorian based calendar systems where week date processing is desired. May not always be the same value as calendar year.
See: Date Field SymbolTable.
Also: ICU Formatting Dates and Times
Your date format string is wrong. Change it to the following:
dateFormatter.dateFormat = "dd MMM yyyy"
For more information read Date Formatters documentation.