DATETIME.GETTIMEZONE(3) 1 DATETIME.GETTIMEZONE(3)DateTime::getTimezone - Return time zone relative to given DateTime
Object oriented style
SYNOPSIS
public DateTimeZone DateTime::getTimezone (void )
DESCRIPTION
DateTimeZone DateTimeImmutable::getTimezone (void ) DateTimeZone DateTimeInterface::getTimezone (void )
Procedural style
DateTimeZone date_timezone_get (DateTimeInterface $object)
Return time zone relative to given DateTime.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3)RETURN VALUES
Returns a DateTimeZone object on success or FALSE on failure.
EXAMPLES
Example #1
DateTime.getTimezone(3) example
Object oriented style
<?php
$date = new DateTime(null, new DateTimeZone('Europe/London'));
$tz = $date->getTimezone();
echo $tz->getName();
?>
Procedural style
<?php
$date = date_create(null, timezone_open('Europe/London'));
$tz = date_timezone_get($date);
echo timezone_name_get($tz);
?>
The above examples will output:
Europe/London
SEE ALSO DateTime.setTimezone(3).
PHP Documentation Group DATETIME.GETTIMEZONE(3)
Check Out this Related Man Page
DATETIME.SUB(3) 1 DATETIME.SUB(3)DateTime::sub - Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
Object oriented style
SYNOPSIS
public DateTime DateTime::sub (DateInterval $interval)
DESCRIPTION
Procedural style
DateTime date_sub (DateTime $object, DateInterval $interval)
Subtracts the specified DateInterval object from the specified DateTime object.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $interval
- A DateInterval object
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
EXAMPLES
Example #1
DateTime.sub(3) example
Object oriented style
<?php
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('P10D'));
echo $date->format('Y-m-d') . "
";
?>
Procedural style
<?php
$date = date_create('2000-01-20');
date_sub($date, date_interval_create_from_date_string('10 days'));
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2000-01-10
Example #2
Further DateTime.sub(3) examples
<?php
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('PT10H30S'));
echo $date->format('Y-m-d H:i:s') . "
";
$date = new DateTime('2000-01-20');
$date->sub(new DateInterval('P7Y5M4DT4H3M2S'));
echo $date->format('Y-m-d H:i:s') . "
";
?>
The above example will output:
2000-01-19 13:59:30
1992-08-15 19:56:58
Example #3
Beware when subtracting months
<?php
$date = new DateTime('2001-04-30');
$interval = new DateInterval('P1M');
$date->sub($interval);
echo $date->format('Y-m-d') . "
";
$date->sub($interval);
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-03-30
2001-03-02
NOTES DateTime.modify(3) is an alternative when using PHP 5.2.
SEE ALSO DateTime.add(3), DateTime.diff(3), DateTime.modify(3).
PHP Documentation Group DATETIME.SUB(3)
hello everyone. im sure someone has run into the problem of timestamping files and end up haveing 2 files with the same name thus over writeing one of them.
In my application i am trying to get a timestamp w/ milliseconds but i am haveing no luck and finding an answer in the man pages.
I know... (3 Replies)
Discussion started by: Optimus_P
3 Replies
2. Forum Support Area for Unregistered Users & Account Problems
Hi,
I am hoping that someone could please be of assistance.
I am living in London and was told that in order to catch up with some friends in South africa who talk on Lagnet, I could do it through this site.
I have absolutely NO idea how.
Could someone please assist me by telling me... (2 Replies)
Here is my code:
DATETIME=1214163003
echo $DATETIME | sed 's/....//' | sed 's/....$//' | read DATEHOUR
echo $DATETIME | sed 's/......//' | sed 's/..$//' | read DATEMIN
echo $DATEHOUR
echo $DATEMIN
The idea is that i need the 16 stored in DATEHOUR and the 30 stored in DATEMIN but when... (4 Replies)
i have this script
#!/bin/sh
for i in Europe/Dublin Europe/Berlin US/Eastern US/Central US/Mountain US/Pacific
do
export TZ=$i
case $1 in
"") echo "`date` $i";;
*) echo "`date` $i" | grep $1;;
esac
done
how would i turn the time into the stand 12 hour time? (1 Reply)
i am reading an i/p file input.txt as below and want to read all filenames as in highlighted in bold below and put them in a different file output.txt. can someone help me with a shell script to do this? thanks in advance
regards
brad
input.txt
---------
START
TYPE:OPT
INIT_SEQ:01... (8 Replies)
hi guys,
i have script like below:
if
then
DATETIME=${1}
fi
pls can anyone explain what does ${1} means? what if i have i have two arguments and have {2} added to the if cond? any links to get this claruified on the syntax? (4 Replies)
input:
ref001, Europe, Belgium, 1001
ref001, Europe, Spain, 203
ref001, Europe, Germany, 457
ref002, America, Canada, 234
ref002, America, US, 87
ref002, America, Alaska, 652
Without using an END section, I need to write all the info related to the same ref number ($1)and continent ($2) on... (9 Replies)
Discussion started by: lucasvs
9 Replies
9. Post Here to Contact Site Administrators and Moderators