General documentation / cheat sheets for various languages and services

Angular.js

date filter https://docs.angularjs.org/api/ng/filter/date

{{date_expression | date}}
{{date_expression | date:format}}
{{date_expression | date:format:timezone}}
Format Interpretation Examples
yyyy 4 digit representation of year 0000-9999
yy 2 digit representation of year, padded 00-99
y variable digit representation of year, unpadded 1-9999
MMMM Name of month in year January-December
MMM Name of month in year Jan-Dec
MM Month in year, padded 01-12
M Month in year 1-12
dd Day in month, padded 01-31
d Day in month 1-31
EEEE Day in week Sunday-Saturday
EEE Day in week Sun-Sat
HH Hour in 24-hour day, padded 00-23
H Hour in 24-hour day 0-23
hh Hour in AM/PM, padded 01-12
h Hour in AM/PM 1-12
mm Minute in hour, padded 00-59
m Minute in hour 0-59
ss Second in minute, padded 00-59
s Second in minute 0-59
.sss Milliseconds, padded 000-999
,sss Milliseconds, padded 000-999
a AM/PM marker AM / PM
Z 4 digit (+sign) timezone offset -1200-+1200
ww ISO 8601 week of year 00-53
w ISO 8601 week of year 0-53

The following localizable formats are also available:

Format Equivalent in en_US locale Example in en_US locale
medium MMM d, y h:mm:ss a Sep 3, 2010 12:05:08 PM
short M/d/yy h:mm a 9/3/10 12:05 PM
fullDate EEEE, MMMM d, y Friday, September 3, 2010
longDate MMMM d, y September 3, 2010
mediumDate MMM d, y Sep 3, 2010
shortDate M/d/yy 9/3/10
mediumTime h:mm:ss a 12:05:08 PM
shortTime h:mm a 12:05 PM

The format string can contain literal values. If these are not matched by any of the format strings, they will be interpolated literally. Otherwise, they will need to be escaped by single quotes, e.g., h 'in the morning'. To output a single quote, escape it as two single quotes, e.g., h 'o''clock'.

Complete examples for dt = Date.parse('2014-12-15T20:50:03.692-0600'); // = 1418611803692:

Code Output Note
{{dt | date:'medium'}} Dec 14, 2014 8:50:03 PM  
{{dt | date:'yyyy-MM-dd HH:mm:ss Z'}} 2014-12-14 20:50:03 -0600  
{{dt | date:'MM/dd/yyyy @ h:mma'}} 12/14/2014 @ 8:50PM  
{{dt | date:"MM/dd/yyyy 'at' h:mma"}} 12/14/2014 at 8:50PM  
{{dt | date:"yyyy-MM-ddTHH:mm:ss.sssZ"}} 2014-12-14T20:50:03.692-0600 ISO 8601 in local timezone
{{dt | date:"yyyy-MM-ddTHH:mm:ss.sss'Z'":'UTC'}} 2014-12-15T02:50:03.692Z ISO 8601 in UTC

Debugging

For closures, running the following in your browser’s console can be helpful to access a controller’s innards:

scope = angular.element($('[ng-controller]')).scope()

Documentation

JSDoc syntax, according to @toddmotto/angularjs-styleguide:

/**
 * @name SomeService
 * @desc Main application Controller
 */
function SomeService (SomeService) {
  /**
   * @name doSomething
   * @desc Does something awesome
   * @param {Number} x - First number to do something with
   * @param {Number} y - Second number to do something with
   * @returns {Number}
   */
  this.doSomething = function (x, y) {
    return x * y
  }
}
angular
  .module('app')
  .service('SomeService', SomeService)