Change the format of a google spreadsheet date to include day of the week - date

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

Related

Crystal Reports - If date field is greater than today then today else date field

I am working on a contract and need a date to be the current date if {month3} is after the current date.
I have tried it every way imaginable, I have 2 scenarios where if {month3} is after the current date it prints {month3}, but if {month3} is prior to the current date it prints the current date and hides part of the text above it.
It works on one but not the other, Go easy on me, it's my first post!
IF TOTEXT({Month3},"MMMM dd, yyyy") >= TOTEXT((Currentdate),"MMMM dd, yyyy") THEN
TOTEXT((Currentdate),"MMMM dd, yyyy")
ELSE
TOTEXT({Month3},"MMMM dd, yyyy")
{Month 3} = 7/30/2020
From contract signing to July 30, 2020
From July 07, 2020 to the start of the official event date
the other one is right
{month3} = 5/18/20
Top sentence is hidden and it says:
From July 07, 2020 to the start of the official event date
It's because you compare text-strings instead of dates. Remove the TOTEXT-function and set the date format directly on the properties of the formula field.
IF {Month3} >= Currentdate THEN
Currentdate
ELSE
{Month3}

How to format date with DateFormatter that includes friendly day and month

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.

How to convert milliseconds to local day, date and time format in swift?

I want to display the date in this format (Wed Jan 10 2018 11:20:17). How to convert milliseconds to this format in swift?I want to get the day as Wed, time as 10:30 AM or PM and the date as 10 Jan.
First convert it in date by dividing it by 1000
var date = Date(timeIntervalSince1970: (1477593000000 / 1000.0))
then use DateFormatter to convert in desired format you need
Note: Not tested in XCODE
var dateFormatter = DateFormatter()
dateFormatter.dateFormat = "E, d MMM yyyy HH:mm:ss"
print(dateFormatter.string(from: date))
Hope it is helpful to you.

Format Date String in momentjs

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)

Date Formatting in Objective C (iOS SDK)

Hope you can help. I am importing the current GMT time for an iPhone App. This is being retrieved via a JSON web service.
I believe I have the correct formatter string however I am getting a different date (time is still correct) when I try to format the date I've retrieved. The JSON date is formatted like this: Sun, 15 May 2011 20:35:31 +0000
In the example below strGMT is the date in the format I've just mentioned.
This is the code I'm using to get retrieved date into my code:
NSLog(#"Current GMT: %#", strGMT);
NSDateFormatter *gmtFormatter=[[NSDateFormatter alloc] init];
[gmtFormatter setDateFormat:#"EEE, dd MMM YYYY HH:mm:ss VVVV"];
//THIS IS NOT REFORMATTING CORRECTLY HERE
NSDate *gmtDateTime=[gmtFormatter dateFromString:strGMT];
NSLog(#"Current Formatted GMT Date: %#", gmtDateTime);
The log is showing the following:
Current GMT: Sun, 15 May 2011 20:35:31 +0000
Current Formatted GMT Date: 2010-12-26 20:35:31 +0000
Have I not got the formatting string correct? Any ideas why it's gone from 15 May 2011 (today) to 26th December 2010?
Kind regards
Paul
The correct format string is #"EEE, dd MMMM yyyy HH:mm:ss VVVV"