Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Converting regular time to CTIME Post 26747 by PGPhantom on Thursday 22nd of August 2002 10:35:11 PM
Old 08-22-2002
I must admit ...

As much as I would like to say that I understand exactly what you are saying - I must admit that I am still at a loss.

Although I understand the code and what it is doing - What is "a port of GNU date for WIN"?

I have the UNIX MKS toolkit installed and it has the UNIX date function but the man page does not list the %s variable and the code you gave does not work so I assume that the "port of GNU date for WIN" is what is missing?

Can you possibly enlighten me further as this would be saving me a lot of work?

Thank you for all your help - It is much appreciated.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help converting date-time value to decimal

Hi I need help to do some calculation in script. I have a monitor program (munin) that I would like to log uptime information from a server. The script looks like this (not complete): #!/bin/sh # server_uptime ### Config Start # Reads the server parameters using the HTTP port with... (7 Replies)
Discussion started by: Jotne
7 Replies

2. UNIX for Advanced & Expert Users

problem with converting time using perl

Hello, I have an AIX 5.3 system and i created a script to get the last login of users. The script goes like this: LAST_LOGIN=`lsuser -a time_last_login $cur_user` TIME_LOGIN=`perl -e 'print scalar localtime("$LAST_LOGIN")'` Actually what i do in these two lines is to set a variable... (2 Replies)
Discussion started by: omonoiatis9
2 Replies

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

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

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

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

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

9. Shell Programming and Scripting

Converting seconds to time

I have a list of time spans in seconds, and want to compute the time span as hh:mm:nn I am coding in bash and have coded the following. However, the results are wrong as "%.0f" rounds the values. Example: ftm: 25793.5 tmspan(hrs,min,sec): 7.16 429.89 25793.50 hh: 7 mm: 10 ss:... (2 Replies)
Discussion started by: kristinu
2 Replies

10. Shell Programming and Scripting

Converting time format as Integer to seconds

Hello, How can we convert date like format 20181004171050 in seconds ? I can able to convert till date but failing for HHMMSS. date -d "20181004" "+%s" output as 1538596800 . But when i add hhmmss it is failing date -d "20181004172000" "+%s" result Invalid date Kindly guide. Regards (16 Replies)
Discussion started by: sadique.manzar
16 Replies
DATETIME.__CONSTRUCT(3) 						 1						   DATETIME.__CONSTRUCT(3)

DateTime::__construct - Returns new DateTime object

       Object oriented style

SYNOPSIS
public DateTime::__construct NULL ([string $time = "now"], [DateTimeZone $timezone]) DESCRIPTION
Procedural style DateTime date_create NULL ([string $time = "now"], [DateTimeZone $timezone]) Returns new DateTime object. PARAMETERS
o $time -A date/time string. Valid formats are explained in Date and Time Formats. Enter NULL here to obtain the current time when using the $timezone parameter. o $timezone - A DateTimeZone object representing the timezone of $time. If $timezone is omitted, the current timezone will be used. Note The $timezone parameter and the current timezone are ignored when the $time parameter either is a UNIX timestamp (e.g. @946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00). RETURN VALUES
Returns a new DateTime instance. Procedural style returns FALSE on failure. ERRORS
/EXCEPTIONS Emits Exception in case of an error. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | If $time contains an invalid date/time format, | | | then an exception is now thrown. Previously an | | | error was emitted. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DateTime.__construct(3) example Object oriented style <?php try { $date = new DateTime('2000-01-01'); } catch (Exception $e) { echo $e->getMessage(); exit(1); } echo $date->format('Y-m-d'); ?> Procedural style <?php $date = date_create('2000-01-01'); if (!$date) { $e = date_get_last_errors(); foreach ($e['errors'] as $error) { echo "$error "; } exit(1); } echo date_format($date, 'Y-m-d'); ?> The above examples will output: 2000-01-01 Example #2 Intricacies of DateTime.__construct(3) <?php // Specified date/time in your computer's time zone. $date = new DateTime('2000-01-01'); echo $date->format('Y-m-d H:i:sP') . " "; // Specified date/time in the specified time zone. $date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru')); echo $date->format('Y-m-d H:i:sP') . " "; // Current date/time in your computer's time zone. $date = new DateTime(); echo $date->format('Y-m-d H:i:sP') . " "; // Current date/time in the specified time zone. $date = new DateTime(null, new DateTimeZone('Pacific/Nauru')); echo $date->format('Y-m-d H:i:sP') . " "; // Using a UNIX timestamp. Notice the result is in the UTC time zone. $date = new DateTime('@946684800'); echo $date->format('Y-m-d H:i:sP') . " "; // Non-existent values roll over. $date = new DateTime('2000-02-30'); echo $date->format('Y-m-d H:i:sP') . " "; ?> The above example will output something similar to: 2000-01-01 00:00:00-05:00 2000-01-01 00:00:00+12:00 2010-04-24 10:24:16-04:00 2010-04-25 02:24:16+12:00 2000-01-01 00:00:00+00:00 2000-03-01 00:00:00-05:00 SEE ALSO
DateTime.createFromFormat(3), DateTimeZone.__construct(3), Date and Time Formats, date.timezone ini setting, date_default_time- zone_set(3), DateTime.getLastErrors(3), checkdate(3). PHP Documentation Group DATETIME.__CONSTRUCT(3)
All times are GMT -4. The time now is 01:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy