473,396 Members | 1,989 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,396 software developers and data experts.

beginner problem - using date("M", $i) where $i is an integer

Hi,

I am trying to use the following function:
echo date("M", $i)
to echo the date that the value of a variable, $i, represents (eg. 1 =
Jan, 5 = May, 11 = Nov). Unfortunetely, it returns only Jan for any
number which I assume is the 1970 date that this function returns when
you screw up. I know that when I have the string value of '2005-05-01'
in a variable, I have to convert it in the following function:
echo date("M", strtotime($strdate))
Is something similar required when I use an integer? Thanks

Burnsy

Jul 17 '05 #1
2 1414


bi******@yahoo.co.uk wrote:
Hi,

I am trying to use the following function:
echo date("M", $i)
to echo the date that the value of a variable, $i, represents (eg. 1 =
Jan, 5 = May, 11 = Nov). Unfortunetely, it returns only Jan for any
number which I assume is the 1970 date that this function returns when
you screw up. I know that when I have the string value of '2005-05-01'
in a variable, I have to convert it in the following function:


The second parameter to the date() function is the number of seconds
since 1970-01-01 (the UNIX beginning of time). To do what you want to
do, use

echo date("M",strtotime('2005-'.$i.'-01'));

Ken

Jul 17 '05 #2
This is slightly more efficient, I think:

echo date("M", mktime(0, 0, 0, $i));

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Clément Collin | last post by:
I working on a GIS project, with Access link which just need a little routine in VBA, but I haven't knowledges in VBA language. It's very simple, and it looks like that in a TPascal way : .......
9
by: bubbakittee | last post by:
I am designing a package of functions to be used by people with very little programming experience (if any) and very little patience. I don't want to scare them with programmerish words like...
3
by: Reney | last post by:
I am using Access Database in my program. The column in the table that I am going to use has date/time value with Medium Time selected. (HH:mm). The program is recording a clock in time to this...
12
by: Emi Lu | last post by:
Hello all, I have a question about "date" & "timestamp" types in PostgreSQL. I want to setup the default value '0000-00-00' and "0000-00-00 00:00:00" for them. However, it seems that PostgreSQL...
1
by: S. van Beek | last post by:
Dear reader, First of all a happy new year. In Report event there is the "On No Date" event but in a Form this event is not available.
2
by: R.A.M. | last post by:
Hello, I have started larning C# and I have a question concerning "using (...)" keyword. For example: using (SqlConnection connection = new SqlConnection(ConnectionString)) {...
5
by: veaux | last post by:
I'm thinking this is easy but can't get it. I have a table with following: Table1 Date 1/1/2007 Table2 Type 0107 (This is MMYY of above) So I'm having trouble using a query to turn the...
13
by: Javad | last post by:
Hello I know that I should get the information of windows internet connections by using "rasapi32.dll" library, and I also have some sample codes, but I can't make them work. My exact need is to...
3
by: ManningFan | last post by:
Due to the way our IT group has set up our servers, we are not allowed to use the Shell() command. We are already doing a similar action with an FTP command. Our code is thus: sExe =...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.