Last active
October 7, 2023 19:42
-
-
Save AshKyd/8843581 to your computer and use it in GitHub Desktop.
A momentjs RFC2822 formatted date string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DATE_RFC2822 = "ddd, DD MMM YYYY HH:mm:ss ZZ"; | |
moment().format(DATE_RFC2822); |
OMG.. Why oh why doesn't @moment put this in their docs?? https://gist.github.com/AshKyd/8843581#gistcomment-1781610
Thank you @redben !
moment.utc().locale('en').format('ddd, DD MMM YYYY HH:mm:ss [GMT]');
As JavaScript's .toUTCString() outputs RFC 2822 formatted date, you can just use:
moment().toDate().toUTCString();
@alanibrus i think you got the simplest answer :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was very useful, thank you!