There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
black screen blue screen boot bsod computer connection crash css dell display driver drivers email error explorer firefox firefox 3 hard drive internet internet explorer itunes laptop lcd malware monitor network networking nvidia outlook outlook 2003 outlook express password printer problem problems ram router security slow software sound sprtcmd.exe trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: no leading zero in week of year?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,198 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
24-Feb-2007, 06:01 PM #1
Solved: no leading zero in week of year?
Is there a way I can get the week of year with no leading zero?? W gives 2 digits with leading zeros and I don't know how to get it to display no leading zero.
PHP Code:
<?php
echo "It is currently the " date("WS") . " week of the year.";
?>
Will output

Quote:
It is currently the 08th week of the year.
How can I remove leading zeros?
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
24-Feb-2007, 07:32 PM #2
simplest way is to put the date("WS") into a string, and check the first character of it, if it's a 0, ignore that part of the string with substr
namenotfound's Avatar
Computer Specs
Distinguished Member with 2,198 posts.
 
Join Date: Apr 2005
Location: New York
Experience: I know what I know, I am
24-Feb-2007, 08:28 PM #3
Good idea.

Ok that worked
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
24-Feb-2007, 08:43 PM #4
You could put it in the same line
PHP Code:
<?php
echo "It is currently the " ltrim(date('WS'),0) . " week of the year.";
?>
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
24-Feb-2007, 09:59 PM #5
Brendan...I completely forgot you could use ltrim to strip more than just whitespace.
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
24-Feb-2007, 10:11 PM #6
It's useful
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:05 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.