Jump to content

Keeping Dates as Text


doubledee

Recommended Posts

In my Payment Form, I have an ExpMonth (e.g. '01') and ExpYear (e.g. '2011').

 

Each value is assigned to $expMonth and $expYear respectively.

 

I then need to combine them and keep the format ('MMYYYY').

 

I am afraid that this code may truncate leading zeros...

 

$expDate = $expMonth . $expYear

 

Will my code work, or do I need to do something else to ensure the Month stays ('MM') and the year stays ('YYYY')?

 

 

Debbie

 

Link to comment
Share on other sites

With PHP's dynamic typing I thought it might strip off the leading zeros and convert the string values into integers...

 

Debbie

 

It is called Week Typing (aka Loose Typing) actually. And no, truncation can't occur as you're concatenating strings and the result will obviously be a string.

Link to comment
Share on other sites

With PHP's dynamic typing I thought it might strip off the leading zeros and convert the string values into integers...

 

Debbie

 

It is called Week Typing (aka Loose Typing) actually. And no, truncation can't occur as you're concatenating strings and the result will obviously be a string.

 

Okay, but my fear was that it would convert '02' to '2' and then concatenate...

 

Anyways...

 

Thanks,

 

 

 

Debbie

 

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.