Re: Formatting Date (m/d/yyyy) To Timestamp
| From: | Aziz Saleh | Date: | Mon, 11 Jan 2021 00:04:01 +0000 |
| Subject: | Re: Formatting Date (m/d/yyyy) To Timestamp | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327400@lists.php.net to get a copy of this message | ||
strtotime converts to timestamp, date can be used to convert it to a
specific format, ex:
echo date("Y-m-d", strtotime('1/1/2021'));
On Sun, Jan 10, 2021 at 7:01 PM Serge Fonville <serge.fonville@gmail.com>
wrote:
> It doesn't seem to work. What I did: $d1 = 'strtotime('1/1/2021'); echo
>> $d1;' Echos: '980053200' That in human form is: 'November 30,
>> -0001' Not
>> what I want... any idea why?
>
> You are converting the timestamp to a string again using echo, this
> outputs a unix epoch. You should instead treat $d1 as
>
> Perhaps if you share a bigger part of your code, it would be easier to be
> of help.
>
>
>
> Kind regards/met vriendelijke groet,
>
> Serge Fonville
>
> http://www.sergefonville.nl
>
>
> Op ma 11 jan. 2021 om 00:51 schreef Talin Sharma <talinsharma.in@gmail.com
> >:
>
>> It doesn't seem to work. What I did: $d1 = 'strtotime('1/1/2021'); echo
>> $d1;' Echos: '980053200' That in human form is: 'November 30,
>> -0001' Not
>> what I want... any idea why?
>>
>>
>> Thanks:
>> Talin Sharma
>>
>>
>> On Sun, Jan 10, 2021 at 6:30 PM Serge Fonville <serge.fonville@gmail.com>
>> wrote:
>>
>>> Hi Talin,
>>>
>>> Would
>>> https://www.php.net/manual/en/function.strtotime.php solve your
>>> conversion problem?
>>>
>>> Kind regards/met vriendelijke groet,
>>>
>>> Serge Fonville
>>>
>>> http://www.sergefonville.nl
>>>
>>>
>>> Op ma 11 jan. 2021 om 00:18 schreef Talin Sharma <
>>> talinsharma.in@gmail.com>:
>>>
>>>> Hi All,
>>>>
>>>> I have a string: '1/1/2021'. I want to turn this into a timestamp for
>>>> entering into MySql. I have tried everything I could find. Please let me
>>>> know how to proceed.
>>>>
>>>> Also, let me know if you need more information.
>>>>
>>>>
>>>> Thanks:
>>>> Talin Sharma
>>>>
>>>