Sponsored Content
Full Discussion: Timezone in +/-HHMM format
Top Forums Shell Programming and Scripting Timezone in +/-HHMM format Post 302165616 by jim mcnamara on Friday 8th of February 2008 09:48:00 AM
Old 02-08-2008
You can reasonably expect a system to support POSIX specifications for the date command. POSIX does not specify a %z. That is a GNU extension. GNU date is a good program, but if he is on a multiuser system, getting GNU date installed may be neither practical nor allowed.

GNU date is clearly not what the OP is now using.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Timezone

Hello again, under hp-ux i have a file /etc/TIMEZONE. here is definied which timezone i am. i dont know who reads this file to set after reading the timezone under /usr/lib/tztab. my 2 questions, who reads the file /etc/TIMEZONE ( which service ) and do i need in the first line to set my... (6 Replies)
Discussion started by: ortsvorsteher
6 Replies

2. UNIX for Dummies Questions & Answers

Timezone

Hi, I got an question about changing timezone thrue command line on a SunOS Release 4.1.2 without restarting the computer. Now it's set on WET and I want to set the timezone to CET (GMT +1) Plz somebody help me. Regards Novisern:confused: (5 Replies)
Discussion started by: Novisern
5 Replies

3. UNIX for Dummies Questions & Answers

timezone

Hi, i am searching to change the timezone on a HP-UX11 system. Since last weekend the summertime started i am not able to change the time to the new time, every day the time changes back to wintertime. I think the problem is that the server is on the wrong timezone. Can someone help me please?... (1 Reply)
Discussion started by: eddyvdv
1 Replies

4. UNIX for Advanced & Expert Users

Timezone

HI ; I got Solaris8 installed oon Sunfire V440 .I have TZ=GMT in /etc/TIMEZONE , but when i log in as root i see the date in GMT+1. So i have every time to "set TZ=GMT ; export $TZ" . How can i set the TZ=GMT at the startup defenitely. Thanks :) (7 Replies)
Discussion started by: oss
7 Replies

5. Solaris

Crontab and timezone

I am running SunOS 5.6. If I login with a ksh shell and type 'date'. I get the correct date and time related to the TZ, that is, >Tuesday July 27 09:50:25 NZST 2004 However, if I run under crontab, I get this. >Mon Jul 26 20:49:00 ESTEDT 2004 My question is; Does anyone know how to fix this... (2 Replies)
Discussion started by: lbeard
2 Replies

6. AIX

Timezone Setting

Hi On several AIX 5.3 LPARs the timezone is currrently set to: TZ=NZST-12NZDT,M9.5.0/02:00,M4.1.0/03:00 Daylight savings in NZ starts on Sun 28th Sep 2008, which is the fourth Sunday. Do I need to change my TZ variable to NZST-12NZDT,M9.4.0/02:00,M4.1.0/03:00 or will AIX interpret the fifth... (2 Replies)
Discussion started by: KiwiP
2 Replies

7. Shell Programming and Scripting

Timezone not changed.

Hi All, While installing Red Hat Linux, I tried changing the timezone to Japan for testing.But the timezone was not set to Japan. I tried other timezones , but they didn't work as well. I am guessing the problem might be due to some missing rpm.Does anyone has any idea or faced a similar... (1 Reply)
Discussion started by: nua7
1 Replies

8. Solaris

TIMEZONE problem..

hii there... can you guys help me with TIMEZONE setting on my solaris box i tried to edit cat /etc/TIMEZONE..but i think it will work after rebooting, but something i did which took me to GMT my problem is i have this issue on a server, and i have to fix this without rebooting. thanks for... (1 Reply)
Discussion started by: 6pound
1 Replies

9. UNIX for Dummies Questions & Answers

Need help with Timezone locale.

HI Gurus, I have a issue. One of our applications needs the data loads with the timezone (CST) but our zones run on GMT. I tried to change the TZ value under /etc/default/init value but it seems to effect the the whole zone. Is there any way I can just set up the TZ as CST for a particular user.... (2 Replies)
Discussion started by: rama krishna
2 Replies

10. HP-UX

Getting numeric timezone on HP-UX

Hi I thought the UNIX command date is universal and so I have been using date +%z to get the numberic timezone offset (e.g. -0500) however on HP-UX, this is not returning expected results; on my machine it returns the name of the time zone (e.g. EST) not numbers. does anyone know... (2 Replies)
Discussion started by: flagman5
2 Replies
DATETIME.CREATEFROMFORMAT(3)						 1					      DATETIME.CREATEFROMFORMAT(3)

DateTime::createFromFormat - Returns new DateTime object formatted according to the specified format

       Object oriented style

SYNOPSIS
publicstatic DateTime DateTime::createFromFormat (string $format, string $time, [DateTimeZone $timezone]) DESCRIPTION
Procedural style DateTime date_create_from_format (string $format, string $time, [DateTimeZone $timezone]) Returns new DateTime object formatted according to the specified format. PARAMETERS
o $format - The format that the passed in string should be in. See the formatting options below. In most cases, the same letters as for the date(3) can be used. The following characters are recognized in the $format parameter string +--------------------------+--------------------------------------+---+ | $format character | | | | | | | | | Description | | | | | | | | Example parsable values | | | | | | +--------------------------+--------------------------------------+---+ | | | | | Day | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | d and j | | | | | | | | | Day of the month, 2 digits with or | | | | without leading zeros | | | | | | | | | | | | 01 to 31 or 1 to 31 | | | | | | | | | | | D and l | | | | | | | | | A textual representation of a day | | | | | | | | | | | | Mon through Sun or Sunday through | | | | Saturday | | | | | | | | | | | S | | | | | | | | | English ordinal suffix for the day | | | | of the month, 2 characters. It's | | | | ignored while processing. | | | | | | | | | | | | st, nd, rd or th. | | | | | | | | | | | z | | | | | | | | | The day of the year (starting from | | | | 0) | | | | | | | | | | | | 0 through 365 | | | | | | | | | | | Month | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | F and M | | | | | | | | | A textual representation of a month, | | | | such as January or Sept | | | | | | | | | | | | January through December or Jan | | | | through Dec | | | | | | | | | | | m and n | | | | | | | | | Numeric representation of a month, | | | | with or without leading zeros | | | | | | | | | | | | 01 through 12 or 1 through 12 | | | | | | | | | | | Year | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | Y | | | | | | | | | A full numeric representation of a | | | | year, 4 digits | | | | | | | | Examples: 1999 or 2003 | | | | | | | | | | | y | | | | | | | | | A two digit representation of a | | | | year (which is assumed to be in the | | | | range 1970-2069, inclusive) | | | | | | | | Examples: 99 or 03 (which will be | | | | interpreted as 1999 and 2003, | | | | respectively) | | | | | | | | | | | Time | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | a and A | | | | | | | | | Ante meridiem and Post meridiem | | | | | | | | | | | | am or pm | | | | | | | | | | | g and h | | | | | | | | | 12-hour format of an hour with or | | | | without leading zero | | | | | | | | | | | | 1 through 12 or 01 through 12 | | | | | | | | | | | G and H | | | | | | | | | 24-hour format of an hour with or | | | | without leading zeros | | | | | | | | | | | | 0 through 23 or 00 through 23 | | | | | | | | | | | i | | | | | | | | | Minutes with leading zeros | | | | | | | | | | | | 00 to 59 | | | | | | | | | | | s | | | | | | | | | Seconds, with leading zeros | | | | | | | | | | | | 00 through 59 | | | | | | | | | | | u | | | | | | | | | Microseconds (up to six digits) | | | | | | | | Example: 45, 654321 | | | | | | | | | | | Timezone | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | e, O, P and T | | | | | | | | | Timezone identifier, or difference | | | | to UTC in hours, or difference to | | | | UTC with colon between hours and | | | | minutes, or timezone abbreviation | | | | | | | | Examples: UTC, GMT, Atlantic/Azores | | | | or +0200 or +02:00 or EST, MDT | | | | | | | | | | | Full Date/Time | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | U | | | | | | | | | Seconds since the Unix Epoch (Janu- | | | | ary 1 1970 00:00:00 GMT) | | | | | | | | Example: 1292177455 | | | | | | | | | | |Whitespace and Separators | | | | | | | | | --- | | | | | | | | --- | | | | | | | | | | | (space) | | | | | | | | | One space or one tab | | | | | | | | Example: | | | | | | | | | | | # | | | | | | | | | One of the following separation | | | | symbol: ;, :, /, ., ,, -, ( or ) | | | | | | | | Example: / | | | | | | | | | | |;, :, /, ., ,, -, ( or ) | | | | | | | | | The specified character. | | | | | | | | Example: - | | | | | | | | | | | ? | | | | | | | | | A random byte | | | | | | | | Example: ^ (Be aware that for UTF-8 | | | | characters you might need more than | | | | one ?. In this case, using * is | | | | probably what you want instead) | | | | | | | | | | | * | | | | | | | | | Random bytes until the next separa- | | | | tor or digit | | | | | | | | Example: * in Y-*-d with the string | | | | 2009-aWord-08 will match aWord | | | | | | | | | | | ! | | | | | | | | | Resets all fields (year, month, day, | | | | hour, minute, second, fraction and | | | | timzone information) to the Unix | | | | Epoch | | | | | | | | Without !, all fields will be set to | | | | the current date and time. | | | | | | | | | | | | | | | | | | | | | Resets all fields (year, month, day, | | | | hour, minute, second, fraction and | | | | timzone information) to the Unix | | | | Epoch if they have not been parsed | | | | yet | | | | | | | | | | | | Y-m-d| will set the year, month and | | | | day to the information found in the | | | | string to parse, and sets the hour, | | | | minute and second to 0. | | | | | | | | | | | + | | | | | | | | | If this format specifier is present, | | | | trailing data in the string will not | | | | cause an error, but a warning | | | | instead | | | | | | | | Use DateTime::getLastErrors to find | | | | out whether trailing data was | | | | present. | | | | | | +--------------------------+--------------------------------------+---+ Unrecognized characters in the format string will cause the parsing to fail and an error message is appended to the returned struc- ture. You can query error messages with DateTime::getLastErrors. If $format does not contain the character ! then portions of the generated time which are not specified in $format will be set to the current system time. If $format contains the character !, then portions of the generated time not provided in $format, as well as values to the left-hand side of the !, will be set to correspond- ing values from the Unix epoch. The Unix epoch is 1970-01-01 00:00:00 UTC. o $time - String representing the time. o $timezone - A DateTimeZone object representing the desired time zone. If $timezone is omitted and $time contains no timezone, the current timezone will be used. Note The $timezone parameter and the current timezone are ignored when the $time parameter either contains 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 or FALSE on failure. EXAMPLES
Example #1 DateTime.createFromFormat(3) example Object oriented style <?php $date = DateTime::createFromFormat('j-M-Y', '15-Feb-2009'); echo $date->format('Y-m-d'); ?> Procedural style <?php $date = date_create_from_format('j-M-Y', '15-Feb-2009'); echo date_format($date, 'Y-m-d'); ?> The above examples will output: 2009-02-15 Example #2 Intricacies of DateTime.createFromFormat(3) <?php echo 'Current time: ' . date('Y-m-d H:i:s') . " "; $format = 'Y-m-d'; $date = DateTime::createFromFormat($format, '2009-02-15'); echo "Format: $format; " . $date->format('Y-m-d H:i:s') . " "; $format = 'Y-m-d H:i:s'; $date = DateTime::createFromFormat($format, '2009-02-15 15:16:17'); echo "Format: $format; " . $date->format('Y-m-d H:i:s') . " "; $format = 'Y-m-!d H:i:s'; $date = DateTime::createFromFormat($format, '2009-02-15 15:16:17'); echo "Format: $format; " . $date->format('Y-m-d H:i:s') . " "; $format = '!d'; $date = DateTime::createFromFormat($format, '15'); echo "Format: $format; " . $date->format('Y-m-d H:i:s') . " "; ?> The above example will output something similar to: Current time: 2010-04-23 10:29:35 Format: Y-m-d; 2009-02-15 10:29:35 Format: Y-m-d H:i:s; 2009-02-15 15:16:17 Format: Y-m-!d H:i:s; 1970-01-15 15:16:17 Format: !d; 1970-01-15 00:00:00 SEE ALSO
DateTime.__construct(3), DateTime.getLastErrors(3), checkdate(3), strptime(3). PHP Documentation Group DATETIME.CREATEFROMFORMAT(3)
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy