Sponsored Content
Top Forums Shell Programming and Scripting unixtime to formatted date time Post 302474147 by ctsgnb on Tuesday 23rd of November 2010 11:49:11 AM
Old 11-23-2010
Code:
date '+%Y%m%d,%H%M%S'

Code:
# date '+%Y%m%d,%H%M%S'
20101123,175038
# date '+%Y.%m.%d-%H:%M:%S'
2010.11.23-17:50:42
# a=`date '+%Y%m%d,%H%M%S'`                <------ or  a=$(date '+%Y%m%d,%H%M%S')
# echo $a
20101123,175117
#

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert DATE string to a formatted text

Hi guys, i need your help. I need to convert a date like this one 20071003071023 , to a formated date like 20071003 07:10:23 . Could this be possible ? Regards, Osramos (6 Replies)
Discussion started by: osramos
6 Replies

2. UNIX for Advanced & Expert Users

find formatted filename with date time

Hi, I operate and use HF radars along the California coast for ocean surface currents. The devices use Mac OS as the control and logging software. The software generates thousands of files a week and while I've used PERL in the past to solve the problems of finding files I come to realize some... (6 Replies)
Discussion started by: dpath2o
6 Replies

3. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

4. Homework & Coursework Questions

Date comparison with 'string date having slashes and time zone' in Bash only

1. The problem statement, all variables and given/known data: I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format . I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies

5. Shell Programming and Scripting

Get Formatted Date from Unix Epoch

Could someone please explain how to get a formatted date from the unix epoch (the number of seconds since Jan 1, 1970) For example., If the input is 1297969816, then the output should be 2011-02-17 in YYYY-MM-DD formatted manner. I am using AIX sh shell. Tried date -d and date --date, these... (4 Replies)
Discussion started by: Jesinth Nirmal
4 Replies

6. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

7. Solaris

modifying date and time and time zone on solaris 5.10 with (redundant server) veritas

I have a cluster of two Solaris server (veritas cluster). one working and the other is standby I am going to change the date on them , and am looking for a secure solution as it is giving an important service. my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies

8. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies

9. Shell Programming and Scripting

awk help reformatting badly formatted time field

I need help reformatting an input file with spaces in the time field (4th field). I want the field to look like “hh:mm” with appropriate embedded zeros, but instead it has “h :m “ if the hour and/or minute are single character. I'm pretty new to scripting and this is beyond me. Any help would... (4 Replies)
Discussion started by: lisep
4 Replies

10. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies
ntp_time(3tcl)						      Network Time Facilities						    ntp_time(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
ntp_time - Tcl Time Service Client SYNOPSIS
package require Tcl 8.0 package require time ?1.2.1? ::time::gettime ?options? timeserver ?port? ::time::getsntp ?options? timeserver ?port? ::time::configure ?options? ::time::cget name ::time::unixtime token ::time::status token ::time::error token ::time::reset token ?reason? ::time::wait token ::time::cleanup token _________________________________________________________________ DESCRIPTION
This package implements a client for the RFC 868 TIME protocol (http://www.rfc-editor.org/rfc/rfc868.txt) and also a minimal client for the RFC 2030 Simple Network Time Protocol (http://www.rfc-editor.org/rfc/rfc2030.txt). RFC 868 returns the time in seconds since 1 January 1900 to either tcp or udp clients. RFC 2030 also gives this time but also provides a fractional part which is not used in this client. COMMANDS
::time::gettime ?options? timeserver ?port? Get the time from timeserver. You may specify any of the options listed for the configure command here. This command returns a token which must then be used with the remaining commands in this package. Once you have finished, you should use cleanup to release all resources. The default port is 37. ::time::getsntp ?options? timeserver ?port? Get the time from an SNTP server. This accepts exactly the same arguments as ::time::gettime except that the default port is 123. The result is a token as per ::time::gettime and should be handled in the same way. Note that it is unlikely that any SNTP server will reply using tcp so you will require the tcludp or the ceptcl package. If a suit- able package can be loaded then the udp protocol will be used by default. ::time::configure ?options? Called with no arguments this command returns all the current configuration options and values. Otherwise it should be called with pairs of option name and value. -protocol number Set the default network protocol. This defaults to udp if the tcludp package is available. Otherwise it will use tcp. -port number Set the default port to use. RFC 868 uses port 37, RFC 2030 uses port 123. -timeout number Set the default timeout value in milliseconds. The default is 10 seconds. -command number Set a command procedure to be run when a reply is received. The procedure is called with the time token appended to the argu- ment list. -loglevel number Set the logging level. The default is 'warning'. ::time::cget name Get the current value for the named configuration option. ::time::unixtime token Format the returned time for the unix epoch. RFC 868 time defines time 0 as 1 Jan 1900, while unix time defines time 0 as 1 Jan 1970. This command converts the reply to unix time. ::time::status token Returns the status flag. For a successfully completed query this will be ok. May be error or timeout or eof. See also ::time::error ::time::error token Returns the error message provided for requests whose status is error. If there is no error message then an empty string is returned. ::time::reset token ?reason? Reset or cancel the query optionally specfying the reason to record for the error command. ::time::wait token Wait for a query to complete and return the status upon completion. ::time::cleanup token Remove all state variables associated with the request. % set tok [::time::gettime ntp2a.mcc.ac.uk] % set t [::time::unixtime $tok] % ::time::cleanup $tok % set tok [::time::getsntp pool.ntp.org] % set t [::time::unixtime $tok] % ::time::cleanup $tok proc on_time {token} { if {[time::status $token] eq "ok"} { puts [clock format [time::unixtime $token]] } else { puts [time::error $token] } time::cleanup $token } time::getsntp -command on_time pool.ntp.org AUTHORS
Pat Thoyts BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category ntp of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
ntp KEYWORDS
NTP, SNTP, rfc 2030, rfc 868, time CATEGORY
Networking COPYRIGHT
Copyright (c) 2002, Pat Thoyts <patthoyts@users.sourceforge.net> ntp 1.2.1 ntp_time(3tcl)
All times are GMT -4. The time now is 04:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy