Sponsored Content
Top Forums Programming Converting a user inputted date to epoch time Post 302556929 by ada on Tuesday 20th of September 2011 05:03:46 AM
Old 09-20-2011
Converting a user inputted date to epoch time

Hi all ,

I need to know how to convert a time stamp entered by the user to be converted to GMT/UTC(epoch time) using mktime() and gmtime()
for exapample the input will be put in the form
ptm.tm_sec = 0;
ptm.tm_min = 59;
ptm.tm_hour = 11;
ptm.tm_mday = 20;
ptm.tm_mon = 9-1;
ptm.tm_year = 2011-1900;
ptm.tm_wday = 0;
ptm.tm_yday = 0;
ptm.tm_isdst = -1;

and this has to be converted to epoch time.

Thanks for your help!!
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

how to convert date time to epoch time in solaris

Hi, Is there any easy way to convert date time(stored in shell variable ) to epoch time in solaris box? As +%s is working on linux but not on solaris, also -d option is not working. Any suggestion please? (6 Replies)
Discussion started by: anshuman0507
6 Replies

3. Homework & Coursework Questions

Need User Inputted Date

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm making my first program with perl and am supposed to allow the user to either use the current date or enter a... (0 Replies)
Discussion started by: Zamereon
0 Replies

4. Shell Programming and Scripting

converting epoch time

Hi, Thanks bartus11 yesterday's code worked fine for me. In meantime I've found another "issue". As you can see highlighted, the time format in my original input in case of two rows which should be duplicited ,is differentwhat I need to do is to convert to this format "20110607-08:03:22"... (4 Replies)
Discussion started by: hernand
4 Replies

5. Shell Programming and Scripting

converting epoch time to ddmmyy format

I can not find a working script or way to do this on sun solaris , can someone please guide me? e.g 1327329935 epoch secs = 012312 (ddmmyy) thanks (5 Replies)
Discussion started by: aliyesami
5 Replies

6. Shell Programming and Scripting

Converting real time to epoch time

# date +%s -d "Mon Feb 11 02:26:04" 1360567564 # perl -e 'print scalar localtime(1360567564), "\n";' Mon Feb 11 02:26:04 2013 the epoch conversion is working fine. but one of my application needs 13 digit epoch time as input 1359453135154 rather than 10 digit epoch time 1360567564... (3 Replies)
Discussion started by: vivek d r
3 Replies

7. Shell Programming and Scripting

Convert epoch time to Julian date

Need assistance in converting an epoch time to Julian date To get epoch perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"' (3 Replies)
Discussion started by: ajayram_arya
3 Replies

8. UNIX for Dummies Questions & Answers

Converting Epoch time

I have a Raspberry Pi that logs some temperatures using Onewire. Data is collected with RRDTool. The command sudo rrdtool fetch ute_temp.rrd AVERAGE -s -1h > ./test.log and then cat test.log gives the result 1388608500: 2.3579639836e+00 . How do I write a script that converts the Epoch time... (4 Replies)
Discussion started by: nilekl
4 Replies

9. Shell Programming and Scripting

Epoch time to produce exact date everytime

so i have to perform a certain task at set times. for instance, i need to run a job at 12:30am every night, and other jobs, i only need to have them run on saturdays. how do i manipulate the date command to give me the epoch equivalence of what 12:30am would be every day? im looking for a... (3 Replies)
Discussion started by: SkySmart
3 Replies

10. Shell Programming and Scripting

Converting a random epoch time into a readable format

I am trying to create a script that will take epoch (input from command line) and convert it into a readable format in bash/shell ---------- Post updated at 08:03 PM ---------- Previous update was at 07:59 PM ---------- #!bin/bash read -p "Please enter a number to represent epoch time:"... (9 Replies)
Discussion started by: sprocket
9 Replies
pts(7)							 Miscellaneous Information Manual						    pts(7)

NAME
pts - STREAMS slave pty (pseudo-terminal) driver SYNOPSIS
DESCRIPTION
A pseudo-terminal (pty) consists of a tightly-coupled pair of character devices, called the master device and slave device. The pty master and slave device drivers work together to simulate a terminal connection where the master provides a connection to the pseudo terminal server process and the slave provides a terminal device special file access for the terminal application processes, as depicted below: ---------------- | pty functions | Application <--> |----------------| <--> Server Processes | Slave | Master | Process | (pts) | (ptm) | ---------------- The slave driver, with (STREAMS pty emulation module) and (STREAMS line discipline module) pushed on top (not shown for simplicity), pro- vides a terminal interface as described in termio(7). Whereas devices that provide the terminal interface described in termio(7) have a hardware device behind them; in contrast, the slave device has another process manipulating it through the master side of the pty. Data written on the master device is given to the slave device as input and data written on the slave device is presented as input on the master device. In order to use the STREAMS pty subsystem, a node for the master pty driver and N number of slave pty devices must be installed (see ptm(7) for more details on master pty). When the master device is opened, the corresponding slave device is automatically locked out. No user can open that slave device until its permissions are changed (via the function) and the device is unlocked (via the function). The user then call the function to obtain the name of the slave device and invoke the system call to open the slave device. Although only one open is allowed on a master device, multiple opens are allowed on the slave device. After both the master and slave have been opened, the user has two file descriptors which represent the end points of a full duplex connection composed of two streams that are automatically con- nected by the master and slave devices when they are opened. The user may then push the desired modules (for example, and on for terminal semantics and on for Packet Mode feature). The master and slave drivers pass all STREAMS messages to their adjacent drivers. Only the message needs some special processing because the read queue of the master is connected to the write queue of the slave and vice versa. For example, the flag is changed to flag and vice versa whenever a message travels across the master-slave link. When the master device is closed, an message is sent to the corre- sponding slave device which will render that slave device unusable. The process on the slave side gets the errno when attempting a system call to the slave device file but it will be able to read any data remaining in the slave stream. Finally, when all the data has been read, the system call will return 0, indicating that the slave can no longer be used. On the last close of the slave device, a zero-length message is sent to the corresponding master device. When the application on the master side issues a read(2) or getmsg(2) system calls, a 0 (zero) is returned. The user of the master device may decide to close the master device file, which dismantles the stream on the master side. If the master device remains opened, the corresponding slave device can be opened and used again by another user. EXAMPLES
The following example shows how a STREAMS pty master and slave devices are typically opened. AUTHOR
was developed by HP and OSF. FILES
Streams pty master clone device Streams pty slave devices (0 <= N < where is a kernel tunable parameter which can be changed via SAM (see sam(1M)). SEE ALSO
insf(1M), sam(1M), getmsg(2), ioctl(2), open(2), read(2), write(2), grantpt(3C), ptsname(3C), unlockpt(3C), ldterm(7), ptem(7), ptm(7), streamio(7), termio(7). pts(7)
All times are GMT -4. The time now is 10:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy