DateService

DateService

Classname : be.securit.trustbuilder.service.DateService

Format variables

  • Letter Date or Time Component Presentation Examples
  • G Era designator Text AD
  • y Year Year 1996; 96
  • M Month in year Month July; Jul; 07
  • w Week in year Number 27
  • W Week in month Number 2
  • D Day in year Number 189
  • d Day in month Number 10
  • F Day of week in month Number 2
  • E Day in week Text Tuesday; Tue
  • a Am/pm marker Text PM
  • H Hour in day (0-23) Number 0
  • k Hour in day (1-24) Number 24
  • K Hour in am/pm (0-11) Number 0
  • h Hour in am/pm (1-12) Number 12
  • m Minute in hour Number 30
  • s Second in minute Number 55
  • S Millisecond Number 978
  • z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
  • Z Time zone RFC 822 time zone -0800

Functions

  • now(format) Format now as specified
  • epoch() Now as epoch number (seconds since 1970)
  • inRange(start,end) Returns true if now is between start and end as epoch dates
  • nowISO8601() Now in ISO8601 format
  • formatISO8601(date,timezone) Date in ISO8601 format where date is in epoch, timezone is a string
  • format(date,format) Date in specific format where date is in epoch
  • calcDateISO8601(expression) Date in expression in ISO8601 format where expression can be +/- x [s|m|h|d]
  • calcDate(expression,format) Date in expression in format where expression can be +/- x [s|m|h|d]
  • calcDateAsEpoch(expression) Date as epoch where expression can be +/- x [s|m|h|d]
  • calcDateAsEpoch(date,expression) Calculate date with expression using date as starting point

formatISO8610()

NormalizedCustomID:
         GMT Sign TwoDigitHours : Minutes
 Sign: one of
         + -
 TwoDigitHours:
         Digit Digit
 Minutes:
         Digit Digit
 Digit: one of
         0 1 2 3 4 5 6 7 8 9

Example :

var time = tb.getService("dateService");
var now = time.epoch();                        // EPOCH : 1395996050671
var iso = time.formatISO8601(now);             // ISO DATE : 2014-03-28T09:40:50.671+01:00
var gmt5 = time.formatISO8601(now,'GMT+05:00'); // NO SPACES !   GMT+5 DATE: 2014-03-28T13:40:50.671+05:00
var zulu = time.formatISO8601(now,'UTC');       // ZULU DATE: 2014-03-28T08:48:38.075Z
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.