Sponsored Content
Top Forums Shell Programming and Scripting conversion of different timestamp to standard timestamp Post 302307086 by quirkasaurus on Tuesday 14th of April 2009 02:23:15 PM
Old 04-14-2009
a slightly more legible version:

Code:
cat << EOF |
2/28/2009 8:03 PM Mchenry: Shawna 2/28/2009 8:03 2/28/2009
3/28/2009 6:03 PM phanj: ray 3/28/2009 8:03 3/28/2009
4/8/2009 4:03 PM hcary: jun 4/8/2009 8:03 4/8/2009
2/9/2009 08:03 PM ghtar: jan 2/09/2009 8:03 2/09/2009
EOF
sed -e 's/[\/:]/ /g' |
nawk '{
  printf( "%04d-%02d-%02d %02d:%02d ", $3, $1, $2, $4, $5 );
  printf( "%s: %s ", $7, $8 );
  printf( "%04d-%02d-%02d %02d:%02d ", $11, $9, $10, $12, $13 );
  printf( "%04d-%02d-%02d 00:00:00", $16, $14, $15 );
  printf( "\n" );
  }'

output:

Code:
2009-02-28 08:03 Mchenry: Shawna 2009-02-28 08:03 2009-02-28 00:00:00
2009-03-28 06:03 phanj: ray 2009-03-28 08:03 2009-03-28 00:00:00
2009-04-08 04:03 hcary: jun 2009-04-08 08:03 2009-04-08 00:00:00
2009-02-09 08:03 ghtar: jan 2009-02-09 08:03 2009-02-09 00:00:00


Last edited by quirkasaurus; 04-14-2009 at 03:23 PM.. Reason: show output
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Timestamp to date conversion in ksh

Hi, I have a file containing timestamp( Example given below). How can i get date(mmd-dd-yyyy) from it? ($> cat file1.txt 2008-11-24 05:17:00.7043) Thanks, Sri (2 Replies)
Discussion started by: srilaxmi
2 Replies

2. Shell Programming and Scripting

[Perl] Timestamp conversion

Hi, I have searched, read and tried, but no luck. I have this code: #!/bin/perl -w #-d use strict; use POSIX qw(strftime); my $getprpw_list="/usr/lbin/getprpw -l"; my $host = "nbsol151"; my $user = "genadmin"; my %uid; my %spwchg; my %upwchg; my %slogint; (2 Replies)
Discussion started by: ejdv
2 Replies

3. Programming

timestamp conversion problem.

Hi all. I have the following code: #include<stdio.h> #include<time.h> int main() { struct tm tm; time_t time = 1262322000; /*Jan, 01, 2010*/ char temp; int i = 0; while(i < 4) { memset(temp, 0, 128); localtime_r(&time,... (2 Replies)
Discussion started by: adm1n
2 Replies

4. AIX

Need timestamp conversion shell script !!

Can anyone provide me with a ksh or bash script which will accept a timestamp (format is YYYY-MM-DD-HH24.Mi.Ss) and time offset (in hours). The output will be (timestamp passed - time offset passed deducted from it) in the same YYYY-MM-DD-HH24.Mi.Ss format. Basically I am trying to convert the... (1 Reply)
Discussion started by: shibajighosh
1 Replies

5. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

6. Shell Programming and Scripting

Timestamp conversion in PERL

Hi, I have a file as below I need to overwrite the 2 nd column alone to numeric format like "06122011030414012345" as per the timestamp value output file should be the microseconds can be neglected if required. Any help will be appreciated. Thanks in advance (1 Reply)
Discussion started by: irudayaraj
1 Replies

7. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

8. Shell Programming and Scripting

GMT to MST timestamp conversion

Hi Team, We have written a perl script to perform the GMT to MST timestamp conversion. Input: 2013-12-01T05:23:19.374 Output: need the given timestamp in MT (MST/MDT) #!/usr/bin/perl use strict; use warnings; use Time::Local; #always gmt #my $tval = '2013-12-01T05:23:19.374'; ... (4 Replies)
Discussion started by: kmanivan82
4 Replies

9. Shell Programming and Scripting

Timestamp conversion

Hello All, I have a file with many timestamps as in below format & example: 20150130105120 2015-> Year in YYYY 01-> Month in MM 30-> Day in DD 10-> Hour in HH 51-> Minute in mm 20-> Seconds in SS This is in GMT. I want to convert all these time stamps in GMT+5:30 format.. Can... (4 Replies)
Discussion started by: ailnilanjan
4 Replies

10. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
DATE_SUNSET(3)								 1							    DATE_SUNSET(3)

date_sunset - Returns time of sunset for a given day and location

SYNOPSIS
mixed date_sunset (int $timestamp, [int $format = SUNFUNCS_RET_STRING], [float $latitude = ini_get("date.default_latitude")], [float $longitude = ini_get("date.default_longitude")], [float $zenith = ini_get("date.sunset_zenith")], [float $gmt_offset]) DESCRIPTION
date_sunset(3) returns the sunset time for a given day (specified as a $timestamp) and location. PARAMETERS
o $timestamp - The $timestamp of the day from which the sunset time is taken. o $format - $format constants +-----------------------+-------------------------------------------+ | constant | | | | | | | description | | | | | | example | | | | +-----------------------+-------------------------------------------+ | SUNFUNCS_RET_STRING | | | | | | | returns the result as string | | | | | | 16:46 | | | | | SUNFUNCS_RET_DOUBLE | | | | | | | returns the result as float | | | | | | 16.78243132 | | | | |SUNFUNCS_RET_TIMESTAMP | | | | | | | returns the result as integer (timestamp) | | | | | | 1095034606 | | | | +-----------------------+-------------------------------------------+ o $latitude - Defaults to North, pass in a negative value for South. See also: date.default_latitude o $longitude - Defaults to East, pass in a negative value for West. See also: date.default_longitude o $zenith - Default: date.sunset_zenith o $gmtoffset - Specified in hours. ERRORS
/EXCEPTIONS Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using the system settings or the $TZ environment variable. See also date_default_timezone_set(3) CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.0 | | | | | | | Now issues the E_STRICT and E_NOTICE time zone | | | errors. | | | | +--------+---------------------------------------------------+ RETURN VALUES
Returns the sunset time in a specified $format on success or FALSE on failure. EXAMPLES
Example #1 date_sunset(3) example <?php /* calculate the sunset time for Lisbon, Portugal Latitude: 38.4 North Longitude: 9 West Zenith ~= 90 offset: +1 GMT */ echo date("D M d Y"). ', sunset time : ' .date_sunset(time(), SUNFUNCS_RET_STRING, 38.4, -9, 90, 1); ?> The above example will output something similar to: Mon Dec 20 2004, sunset time : 18:13 SEE ALSO
date_sunrise(3). PHP Documentation Group DATE_SUNSET(3)
All times are GMT -4. The time now is 10:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy