Jump to content

[SOLVED] I had a book once...


Ryoku

Recommended Posts

I had a book that covered this but its packed up and buried under a mountain of boxes.

 

I'm having some problems messing around with dates.

 

when i try to do something basic to the values PHP returns i lose my leading zero(s).

 

how do you force/require a string to be a certain length?

Link to comment
Share on other sites

don't use sprintf

 

php.net/date

 

will show u all the parameters to return various date items.

 

I actualy started on the php.net manual but its didn't help me with the problem of losing my formatting when i printed the results.

 

after i would explode() the date into an array to work with the numbers once i used any math on the values they lost their formatting.

 

if I'm going to transpose the base date into another value i need to know how to force the length of the string.

Link to comment
Share on other sites

well this is the situation I'm in. I'm messing with functions I'd like to add to, my first, news script.

 

I either have the date provided by PHP from the date() or i have the date retrieved from the entries in my DB server.

 

I'd like the ability to post/pre-date news (to be posted) by adding or subtracting from the int date and still have it compatible with the date format of the DB server where it will end up. but when i attempt to script for pre/post any math i do to the value returns a value of a single digit not 2 digits as the DB formatting requires (to my knowledge)

 

i get 9 where i need 09 [since i did these tests today (08/09/08)]

Link to comment
Share on other sites

well i think i figured out a way, using mkdate() to reformat the date, if i have an idate('Y') to just call the values and manipulate them that way i throw the values back into a date('Y-m-d',mktime(0,0,0,$curmonth,$curdate,$curyear)) i get the result I'm looking for...

 

^solved

 

although it still really dosen't answer my question of how to force a string length, how ever mute, =P i remember a tiny piece of the over all code to pull it off it looked something like this

 

[/./.\\/]

 

but that's all i remember and i have no idea what that example means...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.