Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Next or Previous hours #1737

Closed
caiodounis opened this issue May 27, 2019 · 2 comments
Closed

Parse Next or Previous hours #1737

caiodounis opened this issue May 27, 2019 · 2 comments

Comments

@caiodounis
Copy link

caiodounis commented May 27, 2019

Hello,

It would be nice to use a parse() notation like next 3am or maybe coming 3am to get the coming time it will be 3am. It would help me in the case when I want to set a countdown.

For example, instead of writing:

if(Carbon::now() > Carbon::parse('3am')){
	return Carbon::parse('tomorrow 3am');
}
else{
	return Carbon::parse('3am');
}

I'd write only:

return Carbon::parse('next 3am');

Thanks!

@kylekatarnls
Copy link
Collaborator

Hi @caiodounis, it's planned for 2.20:
#1681

Not yet fully specified but it should allow such operations in one call.

@kylekatarnls
Copy link
Collaborator

This exact syntax will be available on 2.20, I close this issue, you can review the PR #1746 if you have some remarks about the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants