summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/redux/helpers/dateTimeHelper.js
blob: e91c981327b1d9297eebce85e00d66e0fdc4bd8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export function getDate() {
  let today = new Date();
  let dd = today.getDate();
  const monthNames = [
    'January', 'February', 'March', 'April', 'May', 'June',
    'July', 'August', 'September', 'October', 'November', 'December'
  ];
  const mm = monthNames[today.getMonth()]; // January is 0!
  const yyyy = today.getFullYear();

  if (dd < 10) {
    dd = '0' + dd;
  }

  today = mm + ', ' + dd + ' ' + yyyy;

  return today;
}

export function getTime() {
  let now = new Date();
  let h = now.getHours();
  let m = now.getMinutes();

  if (h < 10) {
    h = '0' + h;
  }

  if (m < 10) {
    m = '0' + m;
  }

  now = h + ':' + m;
  return now;
}