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
OFFTIME(3)						   BSD Library Functions Manual 						OFFTIME(3)

NAME
offtime, timeoff, timegm, timelocal -- convert date and time LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <time.h> struct tm * offtime(const time_t * clock, long int offset); struct tm * offtime_r(const time_t * clock, long int offset, struct tm *ret); time_t timeoff(struct tm * tm, long int offset); time_t timegm(struct tm * tm); time_t timelocal(struct tm * tm); DESCRIPTION
These functions are inspired by C standard interfaces named similarly. offtime() converts the calendar time clock, offset by offset seconds, into broken-down time, expressed as Coordinated Universal Time (UTC). offtime_r() is similar to offtime() but it places the returned struct tm * in the user supplied ret argument. timeoff() converts the broken-down time tm, expressed as UTC, offset by offset seconds, into a calendar time value. timegm() converts the broken-down time tm into a calendar time value, effectively being the inverse of gmtime(3). It is equivalent to the C standard function mktime(3) operating in UTC. timelocal() converts the broken down time tm, expressed as local time, into a calendar time value. It is equivalent to the C standard func- tion mktime(3), and is provided for symmetry only. SEE ALSO
ctime(3), tm(3), tzset(3) BSD
April 14, 2011 BSD
All times are GMT -4. The time now is 02:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy