Sponsored Content
Top Forums Shell Programming and Scripting To convert a date(in string format) to unix timestamp Post 302350539 by girish.raos on Friday 4th of September 2009 07:00:13 AM
Old 09-04-2009
Hi Siba,
I tried using the command provided by you, but error outs with the below error mesage.
date: Not a recognized flag: d
Usage: date [-u] [+"Field Descriptors"]

Kindly help .

Thanks,
Giri
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to convert from timestamp to date format in tcsh

hello all im looking for fast way to convert timestamp format to date format and vaiseversa in tcsh , can it be done? thanks allot (2 Replies)
Discussion started by: umen
2 Replies

2. Shell Programming and Scripting

convert unix date to readable format

Dear Experts, I need your help to convert a unix date and time format number in to readable format like dd/mm/yyyy . I have a text file of more than 10,000 records and it is like NAME DATE1 COUNTRY DATE2 ABD 1223580395699 USA 1223580395699... (3 Replies)
Discussion started by: shary
3 Replies

3. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

4. Shell Programming and Scripting

Convert date to Unix format

Dear Expert How to convert date in format of YYYY-MM-DD HH:MM:SS to unix format using a script or command if avaliable Example "2011-05-15 18:00:00" is converted to 1330970400 I tried to use option d in date command but no use, Im using solaris 10 Thanks a lot (12 Replies)
Discussion started by: yahyaaa
12 Replies

5. AIX

convert a specific date to a unix timestamp

hello, i have an AIX5.3 machine and i am writing a script to display some processes. inside the script i want to get the time that the process starts and convert it to a unix timestamp. is there a command that i can use to do that? i search the web but all i found is long scripts and it does... (4 Replies)
Discussion started by: omonoiatis9
4 Replies

6. Shell Programming and Scripting

Convert string into date format

Hi, I am getting the below string as a input for date. 12/03/2013 11:02 AM I want to change this date as 03-DEC-2013 11:02 AM. Could you please help on this. Thanks Chelladurai (4 Replies)
Discussion started by: ckchelladurai
4 Replies

7. Shell Programming and Scripting

Convert UNIX timestamp to readable format in the file

Hello I have a file : file1.txt with the below contents : 237176 test1 test2 1442149024 237138 test3 test4 1442121300 237171 test5 test7 1442112823 237145 test9 test10 1442109600 In the above file fourth field represents the timestamp in Unix format. I found a command which converts... (6 Replies)
Discussion started by: rahul2662
6 Replies

8. Shell Programming and Scripting

Convert date in dd mm yyyy format to UNIX timestamp

Hello All, I have a date in DD/MM/YYYY format. I am trying to convert this into unix timestamp. I have tried following: date -d $mydate +%s where mydate = 23/12/2016 00:00:00 I am getting following error: date: extra operand `+%s' Try `date --help' for more information. ... (1 Reply)
Discussion started by: angshuman
1 Replies

9. Shell Programming and Scripting

Convert string (YYYYMMDD) format to date in Sun OS

Hi All I need help in converting a string of YYYYMMDD format to date in Sun OS and then find out if the day is a Wednesday or not. The "date -d" option is not working and your help is much appreciated. The date command usage from the operating system we use here is as follows: usage: ... (1 Reply)
Discussion started by: SK123
1 Replies

10. Solaris

Convert string (YYYYMMDD) format to date in Sun OS

Hi All I need help in converting a string of YYYYMMDD format to date in Sun OS and then find out if the day is a Wednesday or not. The "date -d" option is not working and your help is much appreciated. The date command usage from the operating system we use here is as follows: Thanks, SK (11 Replies)
Discussion started by: SK123
11 Replies
os(3erl)						     Erlang Module Definition							  os(3erl)

NAME
os - Operating System Specific Functions DESCRIPTION
The functions in this module are operating system specific. Careless use of these functions will result in programs that will only run on a specific platform. On the other hand, with careful use these functions can be of help in enabling a program to run on most platforms. EXPORTS
cmd(Command) -> string() Types Command = string() | atom() Executes Command in a command shell of the target OS, captures the standard output of the command and returns this result as a string. This function is a replacement of the previous unix:cmd/1 ; on a Unix platform they are equivalent. Examples: LsOut = os:cmd("ls"), % on unix platform DirOut = os:cmd("dir"), % on Win32 platform Note that in some cases, standard output of a command when called from another program (for example, os:cmd/1 ) may differ, compared to the standard output of the command when called directly from an OS command shell. find_executable(Name) -> Filename | false find_executable(Name, Path) -> Filename | false Types Name = string() Path = string() Filename = string() These two functions look up an executable program given its name and a search path, in the same way as the underlying operating sys- tem. find_executable/1 uses the current execution path (that is, the environment variable PATH on Unix and Windows). Path , if given, should conform to the syntax of execution paths on the operating system. The absolute filename of the executable program Name is returned, or false if the program was not found. getenv() -> [string()] Returns a list of all environment variables. Each environment variable is given as a single string on the format "VarName=Value" , where VarName is the name of the variable and Value its value. getenv(VarName) -> Value | false Types VarName = string() Value = string() Returns the Value of the environment variable VarName , or false if the environment variable is undefined. getpid() -> Value Types Value = string() Returns the process identifier of the current Erlang emulator in the format most commonly used by the operating system environment. Value is returned as a string containing the (usually) numerical identifier for a process. On Unix, this is typically the return value of the getpid() system call. On VxWorks, Value contains the task id (decimal notation) of the Erlang task. On Windows, the process id as returned by the GetCurrentProcessId() system call is used. putenv(VarName, Value) -> true Types VarName = string() Value = string() Sets a new Value for the environment variable VarName . timestamp() -> {MegaSecs, Secs, MicroSecs} Types MegaSecs = Secs = MicroSecs = int() Returns a tuple in the same format as erlang:now/0 . The difference is that this function returns what the operating system thinks (a.k.a. the wall clock time) without any attempts at time correction. The result of two different calls to this function is not guaranteed to be different. The most obvious use for this function is logging. The tuple can be used together with the function calendar:now_to_universal_time/1 or calendar:now_to_local_time/1 to get calendar time. Using the calendar time together with the MicroSecs part of the return tuple from this function allows you to log timestamps in high resolution and consistent with the time in the rest of the operating system. Example of code formatting a string in the format "DD Mon YYYY HH:MM:SS.mmmmmm", where DD is the day of month, Mon is the textual month name, YYYY is the year, HH:MM:SS is the time and mmmmmm is the microseconds in six positions: -module(print_time). -export([format_utc_timestamp/0]). format_utc_timestamp() -> TS = {_,_,Micro} = os:timestamp(), {{Year,Month,Day},{Hour,Minute,Second}} = calendar:now_to_universal_time(TS), Mstr = element(Month,{"Jan","Feb","Mar","Apr","May","Jun","Jul", "Aug","Sep","Oct","Nov","Dec"}), io_lib:format("~2w ~s ~4w ~2w:~2..0w:~2..0w.~6..0w", [Day,Mstr,Year,Hour,Minute,Second,Micro]). The module above could be used in the following way: 1> io:format("~s~n",[print_time:format_utc_timestamp()]). 29 Apr 2009 9:55:30.051711 type() -> {Osfamily, Osname} | Osfamily Types Osfamily = win32 | unix | vxworks Osname = atom() Returns the Osfamily and, in some cases, Osname of the current operating system. On Unix, Osname will have same value as uname -s returns, but in lower case. For example, on Solaris 1 and 2, it will be sunos . In Windows, Osname will be either nt (on Windows NT), or windows (on Windows 95). On VxWorks the OS family alone is returned, that is vxworks . Note: Think twice before using this function. Use the filename module if you want to inspect or build file names in a portable way. Avoid match- ing on the Osname atom. version() -> {Major, Minor, Release} | VersionString Types Major = Minor = Release = integer() VersionString = string() Returns the operating system version. On most systems, this function returns a tuple, but a string will be returned instead if the system has versions which cannot be expressed as three numbers. Note: Think twice before using this function. If you still need to use it, always call os:type() first. Ericsson AB kernel 2.14.3 os(3erl)
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy