Sponsored Content
Top Forums Shell Programming and Scripting "date" difference between FreeBSD & Linux Post 302462196 by DGPickett on Wednesday 13th of October 2010 01:31:31 PM
Old 10-13-2010
-d in open source date, nice, except my date commands never have it! I took all the C date/time routines and wrote the last date time tool you will ever need:

Code:
$ tm2tm

Usage: tm2tm { -c | { - | <tm_str> } <in_fmt> } <delta> <out_fmt>
 First, gets dates and time(s):
  - when '-c' is used, from gettimeofday() (microsecond system clock)
  - when '-' is used, from the front of each line of stdin per <in_fmt>
  - else, from the front of <tm_str> per <in_fmt>
 The default year is 2000, and for other elements, minimum values.
 The <in_fmt> is either one of these or composed per strptime():
    %s       Absolute Unix time in integer seconds
    %s.%F    Unix time in integer and fractional 6 place seconds
    %s.%f    Unix time in integer and fractional 1-6 place seconds
 Modify each time by <delta>, an optionally sign, integer number,
  and optional suffix indicating the time unit (default seconds):
    Y or y   years           m        months
    D or d   days            H or h   hours
    M        minutes         S or s   seconds
 Format the time by <out_fmt>, which supports all of the strftime() values,
  plus the following:
    %s       Absolute Unix time in seconds
    %F       Fractional 6 place seconds
    %f       Fractional 1-6 place, zero suppressed seconds
 Write the converted time plus any following input data to standard out.
 For example: tm2tm '5/7/05 15:34' '%m/%d/%y %H:%M' -8h '%Y-%m-%d %r %Z'
  prints '2005-05-07 07:34:00 AM EDT'
$

This User Gave Thanks to DGPickett For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Nescape & dial up networking "Linux"

Sorry I need to Know How to connect to the Internet using Netscape in the GUI of the Red Hat Linux .....using phone line with a modem Us robbitics ....Such as in windows We add dial up adapter etc ......:confused: (1 Reply)
Discussion started by: atiato
1 Replies

2. What is on Your Mind?

[[ $(date +%Y) == 2007 ]] && echo "Happy New Year"

Same as the Title! :) (2 Replies)
Discussion started by: ripat
2 Replies

3. Shell Programming and Scripting

Difference between ">/dev/null 2>&1" and "2>&1 >/dev/null"

Does >/dev/null 2>&1 and 2>&1 >/dev/null mean the same? (4 Replies)
Discussion started by: proactiveaditya
4 Replies

4. Solaris

difference between "root" and "usr" packages

Hi, could someone pls enlighten me on the difference between the "root" package and "usr" package? Like in this example: pkginfo -l SUNWGtku | grep -i desc DESC: GTK - The GIMP Toolkit (Usr) and pkginfo -l SUNWGtkr | grep -i desc DESC: GTK - The GIMP Toolkit (Root)... (6 Replies)
Discussion started by: masloff
6 Replies

5. UNIX for Dummies Questions & Answers

Difference between "/bin/bash" & "/bin/sh"

what if the difference between #!/bin/sh and #!/bin/bash I wrote a script with the second heading now when i change my heading to the first one ...the script is not executing well....im not getting the required output....any solution to this problem...or do i have to start the... (3 Replies)
Discussion started by: xerox
3 Replies

6. Red Hat

files having Script which works behind "who" & "w" commands

Dear All, plz print the path of files which have the script of "who" & "w" commands. thnx in advance. (6 Replies)
Discussion started by: saqlain.bashir
6 Replies

7. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

8. Web Development

How would I mod_rewrite "/~a1Pha" and "/=a1Pha" to "/paste/a1Pha.htm"? (internally & externally)

Basically I want to shorten URLs on my html pasting site (pasteht.ml), by using "/~a1Pha" instead of "/paste/a1Pha". The ID is 5 numbers and letters, both cases. For example: /~idnum serves /paste/idnum.htm /=idnum serves /paste/idnum.htm /paste/idnum redirects to /~idnum (to update any old... (0 Replies)
Discussion started by: phillips1012
0 Replies
sttime(3)						    ShapeTools Toolkit Library							 sttime(3)

NAME
stMktime, stWriteTime - date and time handling SYNOPSIS
#include <config.h> #include <sttk.h.h> time_tstMktime (char *string); char*stWriteTime (time_t date); DESCRIPTION
stMktime scans the given string and tries to read a date and time from it. It understands various formats of date strings. The following is a list of all valid formats, optional parts in brackets. [Tue] Jan 5[,] [19]93 This includes the standard asctime(3) format. Jan 5 With no year given, the year defaults to the current year. [19]93/01/05 This notation requires month and day represented by exactly two digits. 5.1.[19]93 This is the usual German notation. 5.1. German notation referencing the current year. A certain time, given together with the date must always have the following form. hours:minutes[:seconds] Each of the fields must be an integer value within the proper range (hours: 0-23, minutes and seconds: 0-59). Values below 10 may be written as one digit numbers. The time value may be placed anywhere in the date string: at the beginning, at the end, or somewhere in the middle. Any amount of white- space may be given between a field of the time value and the separating colon. The time is always considered to be local time. stWriteTime generates a time string similar to asctime(3) from its date argument. SEE ALSO
asctime(3) BUGS
Time Zone Names within the time string (like `MET') are not handled properly. In most cases they will cause a failure. sttk-1.7 Thu Jun 24 17:43:35 1993 sttime(3)
All times are GMT -4. The time now is 05:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy