10-01-2015
Thanks balajesuri.
It works perfectly. I did go through the usage of POSIX/ strftime to understand why you have used -1 for $y[1] (Month) and was able to get the answer.
Thanks again for your help.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to change a date from format dd-mmm-yyyy to mm/dd/yyyy. Is there a way to do this with sed or do you have to write a case statement to convert JAN to 01? Thanks (9 Replies)
Discussion started by: stringzz
9 Replies
2. Shell Programming and Scripting
How to convert the date field from dd/mm/yyyy to yyyy/mm/dd in unix
my script will generate text file which have two fields
one is date and another is name of the server for example this is sample date which I have to sort based on older to newer date the problem is when I found out sort will... (4 Replies)
Discussion started by: pareshan
4 Replies
3. Shell Programming and Scripting
Can't find out how to get the day of the week from a given date, anyone got a code snippet that could help please?
Ta!! (4 Replies)
Discussion started by: couponmeup
4 Replies
4. Shell Programming and Scripting
(Attention: Green PHP newbie !)
I have an online inquiry form, delivering a date in the form yyyy/mm/dd to my feedback form. If the content passes several checks, the form sends an e-mail to me. All works fine. I just would like to receive the date in the form dd/mm/yyyy. I tried with some code,... (6 Replies)
Discussion started by: keyboarder
6 Replies
5. Shell Programming and Scripting
I am trying to get the string containing date - in a specfic format actually, although I think that part is inconsequencial - 1110226^1110226^1110226^1110226^1110226 - through echo or printf or in some other way - created within a cront job and passed as a parameter to a perl script.
Now, I know... (3 Replies)
Discussion started by: v8625
3 Replies
6. Shell Programming and Scripting
Hello,
I am writing a script that parses different logs and produces one. In the source files, the date is in DD MM YYYY HH24:MI:SS format. In the output, it should be in DD MON YYY HH24:MI:SS (ie 25 Jan 2010 16:10:10)
To extract the dates, I am using shell substrings, i.e.:
read line
... (4 Replies)
Discussion started by: Adamm
4 Replies
7. Shell Programming and Scripting
Hi,
How can I convert day of year value in format(yy,doy) to normal formatted (dd.mm.yyyy) string also all of them with awk or awk system function?
in_file.txt
---------
12,043
12,044
12,045
12,046
out_file.txt
----------
12.02.2012
13.02.2012
14.02.2012
15.02.2012
imagine... (5 Replies)
Discussion started by: kocaturk
5 Replies
8. Shell Programming and Scripting
Hi I have a problem with Date format in my code.
1st I am trying to convert today's date to yesterday's using
YESTERDAY3=`perl -e '@y=localtime(time()-86400); printf "%04d/%02d/%02d",$y+1900,$y+1,$y;$y;'`
And once it is done I am trying to using the yesterday date in a grep command to... (3 Replies)
Discussion started by: nithinankam
3 Replies
9. UNIX for Dummies Questions & Answers
I've seen a lot of posts on this and have tried the following:
echo 1257000000| perl -e '($d,$m,$y)=(localtime(time-86400));$m+=1;$y+=1900;printf "$y/$m/$d\n";'
But I am unable to convert a past Epoch date into a format such as YYYY/MM/DD or MM/DD/YYYY.
I am using bash and don't know... (4 Replies)
Discussion started by: newbie2010
4 Replies
10. Shell Programming and Scripting
I am getting output of YYYY-MM-DD and want to change this to DD/MM/YYYY.
When am running the query in 'Todd' to_date(column_name,'DD/MM/YYYY') am getting the required o/p of DD/MM/YYYY, But when am executing the same query(Netezza) in linux server(bash) am getting the output of YYYY-MM-DD
file... (3 Replies)
Discussion started by: Roozo
3 Replies
LEARN ABOUT DEBIAN
data::faker::datetime
Data::Faker::DateTime(3pm) User Contributed Perl Documentation Data::Faker::DateTime(3pm)
NAME
Data::Faker::DateTime - Data::Faker plugin
SYNOPSIS AND USAGE
See Data::Faker
DATA PROVIDERS
unixtime
Return a unix time (seconds since the epoch) for a random time between the epoch and now.
date
Return a random date as a string, using a random date format (see date_format).
time
Return a random time as a string, using a random time format (see time_format).
rfc822
Return an RFC 822 formatted random date. This method may not work on systems using a non-GNU strftime implementation (kindly let me
know if that is the case.)
ampm
Returns am or pm randomly (in the current locale) using one of the formats specified in ampm_format.
time_format
Return a random time format.
date_format
Return a random date format.
ampm_format
Return a random am/pm format.
datetime_format
Return a random date and time format.
month
Return a random month name, unabbreviated, in the current locale.
month_abbr
Return a random month name, abbreviated, in the current locale.
weekday
Return a random weekday name, unabbreviated, in the current locale.
weekday_abbr
Return a random weekday name, abbreviated, in the current locale.
sqldate
Return a random date in the ISO8601 format commonly used by SQL servers (YYYY-MM-DD).
datetime_locale
Return a datetime string in the preferred date representation for the current locale, for a random date.
date_locale
Return a date string in the preferred date representation for the current locale, for a random date.
time_locale
Return a time string in the preferred date representation for the current locale, for a random date.
century
Return a random century number.
dayofmonth
Return a random day of the month.
UTILITY METHODS
Data::Faker::DateTime::timestr($format);
Given a strftime format specifier, this method passes it through to POSIX::strftime along with a random date to display in that format.
Perl passes this through to the strftime function of your system library, so it is possible that some of the formatting tokens used
here will not work on your system.
NOTES AND CAVEATS
Be careful build timestamps from pieces
Be very careful about building date/time representations in formats that are not already listed here. For example if you wanted to get
a date that consists of just the month and day, you should NOT do this:
my $faker = Data::Faker->new();
print join(' ',$faker->month,$faker->dayofmonth)."
";
This is bad because you might end up with 'February 31' for example. Instead you should use the timestr utility function to provide
you a formatted time for a valid date, or better still, write a plugin function that does it:
my $faker = Data::Faker->new();
print $faker->my_short_date()."
";
package Data::Faker::MyExtras;
use base qw(Data::Faker);
use Data::Faker::DateTime;
__PACKAGE__->register_plugin(
my_short_date => sub { Data::Faker::DateTime::timestr('%M %e') },
);
POSIX::strftime
See the documentation above regarding the timestr utility method for some caveats related to strftime and your system library.
SEE ALSO
Data::Faker
AUTHOR
Jason Kohles, <email@jasonkohles.com>
COPYRIGHT AND LICENSE
Copyright 2004-2005 by Jason Kohles
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2005-07-14 Data::Faker::DateTime(3pm)