Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

datetimeinterface.format(3) [php man page]

DATETIMEINTERFACE.FORMAT(3)						 1					       DATETIMEINTERFACE.FORMAT(3)

DateTime::format - Returns date formatted according to given format

       Object oriented style

SYNOPSIS
public string DateTime::format (string $format) DESCRIPTION
string DateTimeImmutable::format (string $format) string DateTimeInterface::format (string $format) Procedural style string date_format (DateTimeInterface $object, string $format) Returns date formatted according to given format. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3) o $format - Format accepted by date(3). RETURN VALUES
Returns the formatted date string on success or FALSE on failure. EXAMPLES
Example #1 DateTimeInterface.format(3) example Object oriented style <?php $date = new DateTime('2000-01-01'); echo $date->format('Y-m-d H:i:s'); ?> Procedural style <?php $date = date_create('2000-01-01'); echo date_format($date, 'Y-m-d H:i:s'); ?> The above example will output: 2000-01-01 00:00:00 NOTES
This method does not use locales. All output is in English. SEE ALSO
date(3). PHP Documentation Group DATETIMEINTERFACE.FORMAT(3)

Check Out this Related Man Page

DATETIMEIMMUTABLE.GETTIMESTAMP(3)					 1					 DATETIMEIMMUTABLE.GETTIMESTAMP(3)

DateTime::getTimestamp - Gets the Unix timestamp

       Object oriented style

SYNOPSIS
public int DateTime::getTimestamp (void ) DESCRIPTION
int DateTimeImmutable::getTimestamp (void ) int DateTimeInterface::getTimestamp (void ) Procedural style int date_timestamp_get (DateTimeInterface $object) Gets the Unix timestamp. PARAMETERS
This function has no parameters. RETURN VALUES
Returns the Unix timestamp representing the date. EXAMPLES
Example #1 DateTimeImmutable.getTimestamp(3) example Object oriented style <?php $date = new DateTime(); echo $date->getTimestamp(); ?> Procedural style <?php $date = date_create(); echo date_timestamp_get($date); ?> The above examples will output something similar to: 1272509157 NOTES
Using U as the parameter to DateTime.format(3) is an alternative when using PHP 5.2. SEE ALSO
DateTime.setTimestamp(3), DateTime.format(3). PHP Documentation Group DATETIMEIMMUTABLE.GETTIMESTAMP(3)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question about Paderabo date script

The date outputs the difference in this format YYYYMD. I think it would be better to have the output as YYYYMMDD. Im having problem processing the format. Thank you (9 Replies)
Discussion started by: kayarsenal
9 Replies

2. UNIX for Dummies Questions & Answers

awk question

Hello all I'm trying to get today's date printed in the following format Ex: Jan followed by 2 spaces followed by 9 When I include a single space in the command ,I get the desired output , echo `date | awk '{print $2 " " $3}'` Jan 9 but when I include 2 spaces in the command ,... (10 Replies)
Discussion started by: luft
10 Replies

3. UNIX for Dummies Questions & Answers

comparing 2 string variables in unix

search=Jul 22 date=Jul 22 if then echo They match >>this piece of code does not detect that search and date are equivalent strings.. what's wrong with it? (17 Replies)
Discussion started by: katdaniel16
17 Replies

4. Shell Programming and Scripting

grep tomorrow's date

Hi guys, I need to find tomorrows date in date fomat and should be in variable. as I need to grep this date in a flat file ie. if today's date is '09 JAN 2009' output should be '10 JAN 2009' unix/perl script will be fine. (21 Replies)
Discussion started by: ssachins
21 Replies

5. Emergency UNIX and Linux Support

Comparing date values stored in a file

Hi all, I have written a script which stores data along with requisite dates in a file. I need to compare the stored date values in the file to obtain the row with the highest date value i.e. the recent most entered record in the file. Please help cause i dont know how we can compare dates in... (10 Replies)
Discussion started by: sumi_mn
10 Replies

6. Shell Programming and Scripting

Renaming multiple files

I have 34 file in a directory that all have different names, however, they do have 1 pattern in commmon. They all have "-10-11-2010" date format in the name. I want to replace the date in the file name with a supplied date or maybe even the system date. I am sure I will be using awk or sed to... (9 Replies)
Discussion started by: Harleyrci
9 Replies

7. Shell Programming and Scripting

help on date.

need the two date's one is curdate -1 (yesterday) and 2nd is curdate-7 date in format Nov 23. a=$(date +%d) echo "$a" b=$(($a-01)) echo "$b" this will fail incase of starting of months. (9 Replies)
Discussion started by: samkhu
9 Replies

8. Shell Programming and Scripting

date -1

I have date in the format YYYYMMDD I need to subtract 1 day from this and get the date in the same format as YYYYMMDD How can I do that? (10 Replies)
Discussion started by: dsravan
10 Replies

9. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

10. UNIX for Dummies Questions & Answers

How to find the date format

I have a requirement where the user send a file. If the file is empty they put datetimestamp(YYYYMMDDHH:MM:SS) otherwise they would be data. I can do cat and get whats in file but how can I see if the data is date timestamp. In short, if format(data in file) = YYYYMMDDHH:MM:SS then... (13 Replies)
Discussion started by: eskay
13 Replies

11. Shell Programming and Scripting

Date validity check

hi All, i have file in which it has 2000 records like, test.txt ==== 2011-03-01 2011-03-01 2011-03-01 2011-03-01 2011-03-01 2011-03-02 2011/03/02 previously i used for loop to find the date check like below, for i in `cat test.txt` do d=`echo $i | cut -c9-10| sed 's/^0*//'`;... (11 Replies)
Discussion started by: mechvijays
11 Replies

12. UNIX for Advanced & Expert Users

Get the date greater than defined date

file.txt 2013-01-01 2013-01-02 2013-01-03 2013-01-04 I need some method to get only date which are greater than 2013-01-03 in a seperate file 2013-01-03 2013-01-04 I have tried cat file.txt | awk -F. '$2 > '2013-01-03' {print $0}' >> a2.txt (9 Replies)
Discussion started by: ATWC
9 Replies

13. Shell Programming and Scripting

Date format change in UNIX .dat file

Hi, I need help to convert the date format in .DAT file in unix. I want to convert 10@@|SWIFT MT568 Extract@@|Apr 14 2014 5:47:52:563PM@@|Apr 14 2014 4:33:47:663PM@@||##| into 10@@|SWIFT MT568 Extract@@|04/14/2014/ 5:47:52:563PM@@|04/14/2014 4:33:47:663PM@@||##| Appreciate... (18 Replies)
Discussion started by: karthikengox
18 Replies

14. Shell Programming and Scripting

Code to compare date

Hi All I have a text file (file.txt) which has a date in YYYYMMDD format in the fourth column. I need to compare and check if that date matches the last date of each month in the same format for all the rows.cat file.txt 1|2|3|20150430 a|b|c|20150430 g|e|f|20150430 . .I have been able to... (11 Replies)
Discussion started by: chatwithsaurav
11 Replies

15. Shell Programming and Scripting

Format your scripts with shfmt

I've been working on a tool to format (style) shell programs, much like gofmt for Go. After much testing and personal use, I'm throwing it out there to see if it's useful to anyone else. GitHub - mvdan/sh: A shell parser and formatter in Go You'll need golang to build and install it. If this... (11 Replies)
Discussion started by: mvdan
11 Replies