473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Convert getdate() to YYYY/MM/DD?

Is any solution to convert "1055901520" to yyyy/mm/dd:

Expand|Select|Wrap|Line Numbers
  1. $date = getdate();
  2. print $date[0]; // return 1055901520
  3.  
Sep 29 '09 #1
4 12297
TheServant
1,168 Expert 1GB
Look here.

You will see that [0] is your timestamp (seconds since unix epoch).
Expand|Select|Wrap|Line Numbers
  1. // To get the year (yyyy) it's
  2. echo $date['year'];
  3. // Month (mm) is:
  4. echo $date['mon'];
  5. // Day (dd) is:
  6. echo $date['mday'];
However, you should really look at the date() function as this is probably what you are after. To do your request would be:
Expand|Select|Wrap|Line Numbers
  1. $today = date("Y/m/d");
  2. echo $today;
With the date() function you can put in a second parameter for inital timestamp if that's what you want. If you do not put an initial timestamp, it takes the current one. time() will get you a current timestamp.

I have tried to tell you other ways to solve your problem, but you can use this if that's all you want:
Expand|Select|Wrap|Line Numbers
  1. $date = date("Y/m/d",getdate());
  2. print $date;
Sep 29 '09 #2
Thank you

But how can i convert timestamp (seconds since unix epoch) to date?
(Converting a number to date)
Sep 29 '09 #3
Dormilich
8,658 Expert Mod 8TB
@Lagon666
previous post, second paragraph.
Sep 29 '09 #4
TheServant
1,168 Expert 1GB
@TheServant
If you read the date() documentation you will see the first parameter is output format ("Y/m/d") and the second is your time stamp (1055901520 or getdate() or blank for current)...
Sep 29 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Spare Brain | last post by:
Hi, I am observing a strange error with the time portion of the java.sql.Date() when using resultSet.getDate() - it always seems to show 12:00:00. The following code prints 2004-10-27...
19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
6
by: David | last post by:
Hi, I have a script in one of my .asp pages which I think is written in VBScript (I did not write it). I would like to know how to do the following in Javascript. Have a combo on my page...
2
by: davidgordon | last post by:
Hi, I have some pages with this VBScript code, which obviously does not work in Firefox. How can I convert this to Javascript in order for my web page to work in Firefox ? It basically fills a...
2
by: Franck | last post by:
Hi, 'm gettin mad about date conversion. Here is the point. Got and add-in for Excel which call functions from a web service (on a remote server) The remote server has regional settings...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
4
by: Ashraf Ansari | last post by:
Hi, How Can I convert MM/dd/yyyy format into dd/MM/yyyy and the date which is converted into dd/MM/yyyy should be in DateTime format. I do not want to store it as a string. Please help ...
1
by: mnarewec | last post by:
Team here is my SQL Pivot view. I want to convert to MS Access View. Please assist USE GO /****** Object: View . Script Date: 10/17/2008 20:41:23 ******/ SET ANSI_NULLS ON GO SET...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.