11-17-2010
How to calculate unix epoch time with DC(Calculator)
Hi All,
In our code we are using below code to calculate the UNIX Epoch Time from the time stamp present in the file.
Can any one explain how the DC operates in below command and how we calculate the UNIX EPOCH time from this.
Date incide the file is 20:26:51
Output we get is 1289943554
File content:
0|0|4|472|2010-11-15 23:22:14|2010-11-15 23:30:06
0|0|3|200|2010-11-15 20:26:51|2010-11-15 20:30:11
Thanks.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
i need to convert below date/time format into epoch time
YYYY-m-d H:M
below the example:
a=`date +"%F %H:%M"`
echo $a
Convert $a to epoch time
------------------------------------------------------------------------
lets take an example
if $a=1.03
here i want the epoch time... (3 Replies)
Discussion started by: ali560045
3 Replies
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
Hi guys,
Im trying to subtract time in ksh script. i.e. basically im querying a database and i want to get the time 10mins before hand..(from)
in ksh
CurrMin=$(date "+%M")
from=`expr $CurrMin - 10`
to=$CurrMin
however if i run this i say at 2 or 3 mins past the hour, i.e.... (7 Replies)
Discussion started by: k00061804
7 Replies
5. Shell Programming and Scripting
Hello,
I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes...
I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes.
To do... (10 Replies)
Discussion started by: worm
10 Replies
6. Shell Programming and Scripting
Dear experts,
I have an epoch time input file such as : -
1302451209564
1302483698948
1302485231072
1302490805383
1302519244700
1302492787481
1302505299145
1302506557022
1302532112140
1302501033105
1302511536485
1302512669550
I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies
7. Shell Programming and Scripting
# 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
8. Shell Programming and Scripting
Hello All,
I have a Perl script I'm writing where I ask the user to enter a "start time" for something. The "$start_time" will be in the format of:
# The Time CLI Option Can be in the format of:
--start-time="1day"
--start-time="2hours"
--start-time="45min"
... (1 Reply)
Discussion started by: mrm5102
1 Replies
9. Shell Programming and Scripting
I have a list of epoch times delimited by "-" as follows:
1335078000 - 1335176700
1335340800 - 1335527400
1335771300 - 1335945600
1336201200 - 1336218000
The corresponding dates are:
20120422 1000 - 20120423 1325
20120425 1100 - 20120427 1450
20120430 1035 - 20120502 1100 ... (3 Replies)
Discussion started by: alex2005
3 Replies
10. Shell Programming and Scripting
I have unix epoch time 1441678454803, Can you please help me to print this time in below format ?
DAY,HOUR,MIN,SEC
Appreciate your help!!!
Thanks,
Prince (7 Replies)
Discussion started by: prince1987
7 Replies
LEARN ABOUT PHP
datetime.__construct
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)