08-30-2019
It's always best in my view to convert date and time strings to unixtime and do all calculations in unixtime and then convert the results back to a time string based on locale (local time information, timezone information, etc.).
It's kinda "nutty" in my view to try to manipulate / process time using formatted strings which are only a string representation of a "time" in the local time format.
That is why we store "time" in databases as unix timestamps. We do not, generally speaking, store "time" as a formatted time string.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work
I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies
2. Shell Programming and Scripting
Hi,
Is it possible to set the two time formats in a single machine. My machine time is in EST and the logs are in PST. What would be the issue, and how to make change of this.? (5 Replies)
Discussion started by: gsiva
5 Replies
3. Shell Programming and Scripting
Hi there, am trying to parse an Apache 'server' config file. A snippet of the config file is shown below:
.....
ProxyPassReverse /foo http://foo.example.com/bar
.....
.....
RewriteRule ^/(.*) http://www.example.com/$1
RewriteRule /redirect https://www.example1.com/$1
........ (7 Replies)
Discussion started by: jy2k7ca
7 Replies
4. Shell Programming and Scripting
Hello,
I have a log file for the year, which contains lines starting with the data in the format of YYYY-MM-DD. I need to get all the lines that contain the DD being 04, how would I do this? I tried using grep "*-*04" but it didn't work.
Any quick one liners I should know about?
Thank you. (2 Replies)
Discussion started by: cpickering
2 Replies
5. Shell Programming and Scripting
I was looking at this script which outputs the two lines which differs less than one sec.
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
use constant SEC_MILIC => 1000;
my $file='infile';
## Open for reading argument file.
open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies
6. Shell Programming and Scripting
Greetings
I have a file formatted like this:
rhino grey weight=1003;height=231;class=heaviest;histology=9,0,0,8
bird white weight=23;height=88;class=light;histology=7,5,1,0,0
turtle green weight=40;height=9;class=light;histology=6,0,2,0... (2 Replies)
Discussion started by: Twinklefingers
2 Replies
7. Shell Programming and Scripting
Hello All,
Below is the excerpt from my Informatica log file which has 4 blocks of lines (starting with WRITER_1_*_1). Like these my log file will have multiple blocks of same pattern.
WRITER_1_*_1> WRT_8161
TARGET BASED COMMIT POINT Thu May 08 09:33:21 2014... (13 Replies)
Discussion started by: Ariean
13 Replies
8. Shell Programming and Scripting
I am developing one script which will take log file name, output file name, date, hour and minute as an argument and based on these inputs, the script will scan and capture all the error(s) that have been triggered from a given time. Example: script should capture all the error after 13:50 on Jan... (2 Replies)
Discussion started by: ROMA3
2 Replies
9. Shell Programming and Scripting
I am trying to do a comparison of files based on their last modified date.
I am pulling the first file from a webapp folder using curl.
curl --silent -I http://localhost:8023/conf/log4j2.xml | grep Last
Last-Modified: Tue, 22 Mar 2016 22:02:18 GMT
The second file is on local disk.
stat... (2 Replies)
Discussion started by: Junaid Subhani
2 Replies
10. Shell Programming and Scripting
The below perl script parses a variety of formats. If I use the numeric text file as input the script works correctly. However using the alpha text file as input there is a black output file. The portion in bold splits the field to parse f or NC_000023.10:g.153297761C>A into a variable $common but... (3 Replies)
Discussion started by: cmccabe
3 Replies
LEARN ABOUT DEBIAN
datetime::format::sqlite
DateTime::Format::SQLite(3pm) User Contributed Perl Documentation DateTime::Format::SQLite(3pm)
NAME
DateTime::Format::SQLite - Parse and format SQLite dates and times
SYNOPSIS
use DateTime::Format::SQLite;
my $dt = DateTime::Format::SQLite->parse_datetime( '2003-01-16 23:12:01' );
# 2003-01-16 23:12:01
DateTime::Format::SQLite->format_datetime($dt);
DESCRIPTION
This module understands the formats used by SQLite for its "date", "datetime" and "time" functions. It can be used to parse these formats
in order to create DateTime objects, and it can take a DateTime object and produce a timestring accepted by SQLite.
NOTE: SQLite does not have real date/time types but stores everything as strings. This module deals with the date/time strings as
understood/returned by SQLite's "date", "time", "datetime", "julianday" and "strftime" SQL functions. You will usually want to store your
dates in one of these formats.
METHODS
This class offers the methods listed below. All of the parsing methods set the returned DateTime object's time zone to the UTC zone
because SQLite does always uses UTC for date calculations. This means your dates may seem to be one day off if you convert them to local
time.
o parse_datetime($string)
Given a $string representing a date, this method will return a new "DateTime" object.
The $string may be in any of the formats understood by SQLite's "date", "time", "datetime", "julianday" and "strftime" SQL functions or
it may be in the format returned by these functions (except "strftime", of course).
The time zone for this object will always be in UTC because SQLite assumes UTC for all date calculations.
If $string contains no date, the parser assumes 2000-01-01 (just like SQLite).
If given an improperly formatted string, this method may die.
o parse_date($string)
o parse_time($string)
o parse_julianday($string)
These are aliases for "parse_datetime", for symmetry with "format_*" functions.
o format_date($datetime)
Given a "DateTime" object, this methods returnes a string in the format YYYY-MM-DD, i.e. in the same format SQLite's "date" function
uses.
o format_time($datetime)
Given a "DateTime" object, this methods returnes a string in the format HH:MM:SS, i.e. in the same format SQLite's "time" function
uses.
o format_datetime($datetime)
Given a "DateTime" object, this methods returnes a string in the format YYYY-MM-DD HH:MM:SS, i.e. in the same format SQLite's
"datetime" function uses.
o format_julianday($datetime)
Given a "DateTime" object, this methods returnes a string in the format DDDDDDDDDD, i.e. in the same format SQLite's "julianday"
function uses.
AUTHOR
Claus Faerber <CFAERBER@cpan.org>
based on "DateTime::Format::MySQL" by David Rolsky.
Copyright X 2008 Claus Faerber.
Copyright X 2003 David Rolsky.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
SEE ALSO
http://datetime.perl.org/
http://www.sqlite.org/lang_datefunc.html
perl v5.10.1 2009-12-10 DateTime::Format::SQLite(3pm)