11-21-2010
Date from GNU to BSD
Dear all,
This should be simple but I cannot figure it out despite reading all the man pages. Could someone please help me translate this code (GNU date) to one that can be read by BSD date?:
myDate=$(date -d "$h -$l days" +%Y/%m/%d),
where h is a variable of the form DD/MM/YYYY, and l is a simple integer.
So basically, I want to take the date that is stored in h, add l days to it, and format it as YYYY/MM/DD.
Alternatively, is there a way to force my mac to use GNU date instead of BSD date?
Thank you!
Tom
9 More Discussions You Might Find Interesting
1. BSD
for all you unix/linux interested heres an online book for free that covers the basics of BSD SysV Unix commands and applications . giving the average linux user a perspective on the differences in context of the two operating systems and for BSD users covers material as a refernce guide.
... (0 Replies)
Discussion started by: moxxx68
0 Replies
2. UNIX for Dummies Questions & Answers
I know there are some posts on getting the time with milliseconds included and I realize unix may not be the best on this.
I have seem some posts where its advised to install the GNU date.
Any one know where I can download this as I am struggling to find it.
Alternatively - if you have... (5 Replies)
Discussion started by: frustrated1
5 Replies
3. BSD
Is anyone using or planning to use GNU BSD in production yet? I'd like to hear experiences. (Debian GNU/NetBSD) (8 Replies)
Discussion started by: vpsville
8 Replies
4. UNIX for Dummies Questions & Answers
I use GNU (parted)set to change boot flags when doing multibooting.
Alas, FreeBSD does not have GNU parted, out of the box.
Is there a way to set/remove flags quickly and easily from the command line in BSD? I'm still learning all the 'unique' BSD utilities. (7 Replies)
Discussion started by: uiop44
7 Replies
5. Shell Programming and Scripting
Should work in any shell, but requires GNU date, although GNU date seems only to be happy for input dates between 1902 and 2037, inclusive (49673 days).
Assume $a and $b hold two dates, e.g.
set a=2010-03-27
set b=2010-04-04
Marginally faster:
iterator: seq -f "$a +%1.0f days" 1 50000 |... (0 Replies)
Discussion started by: laddiebuck
0 Replies
6. UNIX for Dummies Questions & Answers
It's easy as pie to get the date minus one day on opensolaris:
date -d "-1 day" +"%Y%m%d"run this command on our crappy Solaris 10 machines however (which I'm guessing doesn't have GNU date running on it) and you get:
date: illegal option -- d
date: illegal option -- 1
date: illegal option --... (5 Replies)
Discussion started by: rich@ardz
5 Replies
7. Shell Programming and Scripting
Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong.
Secondly, I am not interested in... (0 Replies)
Discussion started by: AntumDeluge
0 Replies
8. UNIX for Advanced & Expert Users
Hello All,
Greetings all !!
I have a query here, following are the points on same(Adding today's is 31st August 2016 for future reference).
1st Scenario: So while doing some work on GNU date, I wanted to check what was the month(in numbers) by GNU date so I have done following.
date... (2 Replies)
Discussion started by: RavinderSingh13
2 Replies
9. Shell Programming and Scripting
So as I write this today is two days after the clocks go back here in the UK. I have a script that worked last week. Yesterday it developed a bug. I eventually found the culprit is Gnu Date.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS... (10 Replies)
Discussion started by: apmcd47
10 Replies
LEARN ABOUT SUSE
email::date::format
Email::Date::Format(3) User Contributed Perl Documentation Email::Date::Format(3)
NAME
Email::Date::Format - produce RFC 2822 date strings
SYNOPSIS
use Email::Date::Format qw(email_date);
my $header = email_date($date->epoch);
Email::Simple->create(
header => [
Date => $header,
],
body => '...',
);
DESCRIPTION
This module provides a simple means for generating an RFC 2822 compliant datetime string. (In case you care, they're not RFC 822 dates,
because they use a four digit year, which is not allowed in RFC 822.)
FUNCTIONS
email_date
my $date = email_date; # now
my $date = email_date( time - 60*60 ); # one hour ago
"email_date" accepts an epoch value, such as the one returned by "time". It returns a string representing the date and time of the
input, as specified in RFC 2822. If no input value is provided, the current value of "time" is used.
"format_date" is exported only if requested.
email_gmdate
my $date = email_gmdate;
"email_gmdate" is identical to "email_date", but it will return a string indicating the time in Greenwich Mean Time, rather than local
time.
"format_gmdate" is exported only if requested.
PERL EMAIL PROJECT
This module is maintained by the Perl Email Project
<http://emailproject.perl.org/wiki/Email::Date::Format>
AUTHOR
Ricardo SIGNES, <rjbs@cpan.org>.
Adapted from Email::Date, by Casey West.
COPYRIGHT
Copyright (c) 2007, Ricarod SIGNES. This module is free software; you can redistribute it and/or modify it under the same terms as Perl
itself.
perl v5.12.1 2007-12-03 Email::Date::Format(3)