Skip to main content
added 80 characters in body
Source Link
Zombo
  • 1
  • 7
  • 47
  • 65

You can use the awk Velour librarydate -d is specific to GNU Date and is not defined by POSIX:

velour -n 'print t_secday(t_utc("2017-4-12") - t_utc("2017-4-5"))'

Orhttps://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html

As others have mentioned, this is something that might be better suited to a proper programming language. For example PHP:

velour -n 'print t_secday(t_utc(ARGV[1]) - t_utc(ARGV[2]))' 2017-4-12 2017-4-5
<?php
$o1 = date_create('2020-02-26');
$o2 = date_create('2020-02-16');
$o3 = date_diff($o2, $o1);
echo 'days: ', $o3->d, "\n";

Result:

7
days: 10

You can use the awk Velour library:

velour -n 'print t_secday(t_utc("2017-4-12") - t_utc("2017-4-5"))'

Or:

velour -n 'print t_secday(t_utc(ARGV[1]) - t_utc(ARGV[2]))' 2017-4-12 2017-4-5

Result:

7

date -d is specific to GNU Date and is not defined by POSIX:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html

As others have mentioned, this is something that might be better suited to a proper programming language. For example PHP:

<?php
$o1 = date_create('2020-02-26');
$o2 = date_create('2020-02-16');
$o3 = date_diff($o2, $o1);
echo 'days: ', $o3->d, "\n";

Result:

days: 10
deleted 57 characters in body
Source Link
Zombo
  • 1
  • 7
  • 47
  • 65

You can use the POSIX Awkawk stdlib libraryVelour library:

awklibvelour 'BEGIN-n {print'print t_secday(tm_datet_utc("2017-4-12") - tm_datet_utc("2017-4-5")) / tm_day(1)}'

Or:

awklibvelour 'BEGIN-n {print'print t_secday(tm_datet_utc(ARGV[1]) - tm_datet_utc(ARGV[2])) / tm_day(1)}' 2017-4-12 2017-4-5

Result:

7

You can use the POSIX Awk stdlib library:

awklib 'BEGIN {print (tm_date("2017-4-12") - tm_date("2017-4-5")) / tm_day(1)}'

Or:

awklib 'BEGIN {print (tm_date(ARGV[1]) - tm_date(ARGV[2])) / tm_day(1)}' 2017-4-12 2017-4-5

Result:

7

You can use the awk Velour library:

velour -n 'print t_secday(t_utc("2017-4-12") - t_utc("2017-4-5"))'

Or:

velour -n 'print t_secday(t_utc(ARGV[1]) - t_utc(ARGV[2]))' 2017-4-12 2017-4-5

Result:

7
added 85 characters in body
Source Link
Zombo
  • 1
  • 7
  • 47
  • 65

You can use the POSIX Awk stdlib library:

  
$awklib 'BEGIN {print (tm_date("2017-4-12") - tm_date("2017-4-5")) / tm_day(1)}'

Or:

awklib 'BEGIN {print strtotime(tm_date(ARGV[1]) - strtotimetm_date(ARGV[2])) / tm_day(1)}' 2017-34-1812 2017-34-175
86400

Result:

7

You can use the POSIX Awk stdlib library:

 
$ awklib 'BEGIN {print strtotime(ARGV[1]) - strtotime(ARGV[2])}' 2017-3-18 2017-3-17
86400

You can use the POSIX Awk stdlib library:

 
awklib 'BEGIN {print (tm_date("2017-4-12") - tm_date("2017-4-5")) / tm_day(1)}'

Or:

awklib 'BEGIN {print (tm_date(ARGV[1]) - tm_date(ARGV[2])) / tm_day(1)}' 2017-4-12 2017-4-5

Result:

7
deleted 109 characters in body
Source Link
Zombo
  • 1
  • 7
  • 47
  • 65
Loading
Source Link
Zombo
  • 1
  • 7
  • 47
  • 65
Loading